Skip to content

Commit

Permalink
Added externalTxId parameter and setter for externalTxId.
Browse files Browse the repository at this point in the history
Added the value of externalTxId to transaction creation.

externalTxId will get one of:
- a string (singular usage, must be replaced after a use)
- a function that returns a string (used to generate random strings)
- undefined for no externalTxId
  • Loading branch information
a0ngo committed Aug 18, 2022
1 parent cb387f7 commit 0d190d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class FireblocksWeb3Provider extends EthereumProvider {
private chainId?: number;
private feeLevel: FeeLevel;
private note: string;
private externalTxId: string | undefined;
private externalTxId: (()=>string) | string | undefined;
private accountsPopulatedPromise: Promise<void>;
private pollingInterval: number;
private oneTimeAddressesEnabled: boolean;
Expand Down Expand Up @@ -303,7 +303,7 @@ export class FireblocksWeb3Provider extends EthereumProvider {
feeLevel: (isEip1559Fees || isLegacyFees) ? undefined : this.feeLevel,
destination: this.getDestination(transaction.to),
note: this.note,
externalTxId: this.externalTxId,
externalTxId: !this.externalTxId ? undefined : (typeof this.externalTxId == 'function' ? this.externalTxId() : this.externalTxId),
amount: formatEther(transaction.value?.toString() || "0"),
extraParameters: transaction.data ? {
contractCallData: transaction.data
Expand Down Expand Up @@ -354,7 +354,7 @@ export class FireblocksWeb3Provider extends EthereumProvider {
id: vaultAccountId.toString(),
},
note: this.note,
externalTxId: this.externalTxId,
externalTxId: !this.externalTxId ? undefined : (typeof this.externalTxId == 'function' ? this.externalTxId() : this.externalTxId),
extraParameters: {
rawMessageData: {
messages: [message]
Expand Down Expand Up @@ -395,4 +395,8 @@ export class FireblocksWeb3Provider extends EthereumProvider {
private getVaultAccountId(address: string): number {
return parseInt(Object.entries(this.accounts).find(([id, addr]) => addr.toLowerCase() === address.toLowerCase())?.[0] || '');
}

setExternalTxId(externalTxId: (()=>string) | string | undefined){
this.externalTxId = externalTxId;
}
}
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ export type FireblocksProviderConfig = {
note?: string,
pollingInterval?: number,
oneTimeAddressesEnabled?: boolean,
externalTxId?: string,
externalTxId?: (() => string) | string,
}

0 comments on commit 0d190d4

Please sign in to comment.