Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added getRwaAssetByMint to RpcClient #71

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion src/RpcClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class RpcClient {
constructor(
protected readonly connection: Connection,
protected readonly id?: string
) {}
) { }

/**
* Request an allocation of lamports to the specified address
Expand Down Expand Up @@ -174,6 +174,40 @@ export class RpcClient {
throw new Error(`Error in getAsset: ${error}`);
}
}

/**
* Get RWA Asset by mint.
* @param {DAS.GetRwaAssetRequest} - RWA Asset ID
* @returns {Promise<DAS.GetRwaAssetResponse>}
* @throws {Error}
*/
async getRwaAsset(
params: DAS.GetRwaAssetRequest
): Promise<DAS.GetRwaAssetResponse> {
try {
const url = `${this.connection.rpcEndpoint}`;
const response = await axios.post(
url,
{
jsonrpc: "2.0",
id: this.id,
method: "getRwaAccountsByMint",
params,
},
{
headers: {
"Content-Type": "application/json",
},
}
);

const result = response.data.result;
return result as DAS.GetRwaAssetResponse;
} catch (error) {
throw new Error(`Error in getRwaAsset: ${error}`);
}
}

/**
* Get multiple assets.
* @returns {Promise<DAS.GetAssetResponse[]>}
Expand Down
Loading