Skip to content
This repository was archived by the owner on May 28, 2022. It is now read-only.

Commit 0c63903

Browse files
committed
setDetails for token
1 parent 3fa5124 commit 0c63903

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

typescript/nomad-sdk/src/nomad/NomadContext.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,48 @@ export class NomadContext extends MultiProvider {
498498
return message as TransferMessage;
499499
}
500500

501+
/**
502+
* Send tokens from one domain to another. Approves the bridge if necessary.
503+
*
504+
* @param token The token to update details for
505+
* @param domains An array of the domains to updateDetails on
506+
* @param overrides Any tx overrides (e.g. gas price)
507+
* @returns a {@link TransferMessage} object representing the in-flight
508+
* transfer
509+
* @throws On missing signers, missing tokens, tx issues, etc.
510+
*/
511+
async setDetails(
512+
token: TokenIdentifier,
513+
domains: (string | number)[],
514+
overrides: ethers.Overrides = {},
515+
): Promise<ethers.ContractReceipt[]> {
516+
// get canonical token contract & query canonical details
517+
const { name, symbol, decimals } = await this.getCanonicalTokenDetails(
518+
token,
519+
);
520+
// for each domain, setDetails
521+
const receiptPromises: Promise<ethers.ContractReceipt>[] = [];
522+
for (const domain of domains) {
523+
// get the token representation on that chain
524+
const representation = await this.resolveRepresentation(domain, token);
525+
if (!representation) {
526+
throw new Error(`Token not available on ${domain}`);
527+
}
528+
// send setDetails transaction
529+
const tx = await representation.setDetails(
530+
name,
531+
symbol,
532+
decimals,
533+
overrides,
534+
);
535+
// push transaction receipt promise
536+
const receiptPromise = tx.wait();
537+
receiptPromises.push(receiptPromise);
538+
}
539+
// return all transaction promises
540+
return Promise.all(receiptPromises);
541+
}
542+
501543
/**
502544
* Queries the name, symbol and details of a canonical token.
503545
*

0 commit comments

Comments
 (0)