Skip to content

Commit efcc6fa

Browse files
author
Collin K. Cusce
committed
Merge branch 'master' of https://github.com/ava-labs/avalanchejs
2 parents daeab44 + 42a91a6 commit efcc6fa

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/apis/platformvm/api.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,31 @@ export class PlatformVMAPI extends JRPCAPI {
127127
/**
128128
* Fetches the AVAX AssetID and returns it in a Promise.
129129
*
130+
* @param refresh This function caches the response. Refresh = true will bust the cache.
131+
*
130132
* @returns The the provided string representing the AVAX AssetID
131133
*/
132-
getAVAXAssetID = async ():Promise<Buffer> => {
133-
if (typeof this.AVAXAssetID === 'undefined') {
134+
getAVAXAssetID = async (refresh:boolean = false):Promise<Buffer> => {
135+
if (typeof this.AVAXAssetID === 'undefined' || refresh) {
134136
const assetID:string = await this.getStakingAssetID();
135137
this.AVAXAssetID = bintools.cb58Decode(assetID);
136138
}
137139
return this.AVAXAssetID;
138140
};
141+
142+
/**
143+
* Overrides the defaults and sets the cache to a specific AVAX AssetID
144+
*
145+
* @param avaxAssetID A cb58 string or Buffer representing the AVAX AssetID
146+
*
147+
* @returns The the provided string representing the AVAX AssetID
148+
*/
149+
setAVAXAssetID = (avaxAssetID:string | Buffer) => {
150+
if(typeof avaxAssetID === "string") {
151+
avaxAssetID = bintools.cb58Decode(avaxAssetID);
152+
}
153+
this.AVAXAssetID = avaxAssetID;
154+
}
139155

140156
/**
141157
* Gets the default tx fee for this chain.

0 commit comments

Comments
 (0)