Skip to content

Commit

Permalink
Add public key to schema, tested
Browse files Browse the repository at this point in the history
  • Loading branch information
jurevans committed Jul 7, 2023
1 parent 83a4672 commit 87f8de2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/types/src/tx/schema/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@ export class TxMsgValue {
fee_amount: BN;
gas_limit: BN;
chain_id: string;
public_key?: string;

constructor(properties: TxProps | SchemaObject<typeof TxMsgSchema>) {
this.token = properties.token;
this.fee_amount = 'feeAmount' in properties ?
new BN(properties.feeAmount.toString()) :
properties.fee_amount;
this.gas_limit = 'gasLimit' in properties ?
new BN(properties.gasLimit.toString()) :
properties.gas_limit;
this.chain_id = 'chainId' in properties ?
properties.chainId :
properties.chain_id;
this.fee_amount =
"feeAmount" in properties
? new BN(properties.feeAmount.toString())
: properties.fee_amount;
this.gas_limit =
"gasLimit" in properties
? new BN(properties.gasLimit.toString())
: properties.gas_limit;
this.chain_id =
"chainId" in properties ? properties.chainId : properties.chain_id;
this.public_key =
"publicKey" in properties ? properties.publicKey : undefined;
}
}

Expand All @@ -31,6 +35,7 @@ export const TxMsgSchema = [
["fee_amount", "u64"],
["gas_limit", "u64"],
["chain_id", "string"],
["public_key", { kind: "option", type: "string" }],
],
},
] as const; // needed for SchemaObject to deduce types correctly
1 change: 1 addition & 0 deletions packages/types/src/tx/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type TxProps = {
feeAmount: BigNumber;
gasLimit: BigNumber;
chainId: string;
publicKey?: string;
};

export type TransferProps = {
Expand Down

0 comments on commit 87f8de2

Please sign in to comment.