Skip to content

Commit

Permalink
Added getRwaAssetByMint to RpcClient (#71)
Browse files Browse the repository at this point in the history
* Added getRwaAssetByMint to RpcClient

* Update src/types/types.ts

Co-authored-by: Nikhil Acharya Prakash <niks3089@gmail.com>

---------

Co-authored-by: Evan <96965321+0xIchigo@users.noreply.github.com>
Co-authored-by: Nikhil Acharya Prakash <niks3089@gmail.com>
  • Loading branch information
3 people authored Mar 20, 2024
1 parent cb24cf0 commit d48e4ee
Show file tree
Hide file tree
Showing 3 changed files with 345 additions and 260 deletions.
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

0 comments on commit d48e4ee

Please sign in to comment.