Skip to content

Commit

Permalink
Reformat SCHEMA to make it easier to read field lists
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrichina committed Aug 29, 2019
1 parent 1e36e53 commit ce23775
Showing 1 changed file with 46 additions and 12 deletions.
58 changes: 46 additions & 12 deletions src.ts/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,26 @@ export class Action extends Enum {
}

const SCHEMA = new Map<Function, any>([
[Signature, {kind: 'struct', fields: [['keyType', 'u8'], ['data', [32]]]}],
[SignedTransaction, {kind: 'struct', fields: [['transaction', Transaction], ['signature', Signature]]}],
[Transaction, { kind: 'struct', fields: [['signerId', 'string'], ['publicKey', PublicKey], ['nonce', 'u64'], ['receiverId', 'string'], ['blockHash', [32]], ['actions', [Action]]] }],
[PublicKey, {
kind: 'struct', fields: [['keyType', 'u8'], ['data', [32]]] }],
[Signature, {kind: 'struct', fields: [
['keyType', 'u8'],
['data', [32]]
]}],
[SignedTransaction, {kind: 'struct', fields: [
['transaction', Transaction],
['signature', Signature]
]}],
[Transaction, { kind: 'struct', fields: [
['signerId', 'string'],
['publicKey', PublicKey],
['nonce', 'u64'],
['receiverId', 'string'],
['blockHash', [32]],
['actions', [Action]]
]}],
[PublicKey, { kind: 'struct', fields: [
['keyType', 'u8'],
['data', [32]]
]}],
[AccessKey, { kind: 'struct', fields: [
['nonce', 'u64'],
['permission', AccessKeyPermission],
Expand All @@ -168,13 +183,32 @@ const SCHEMA = new Map<Function, any>([
['deleteAccount', deleteAccount],
]}],
[CreateAccount, { kind: 'struct', fields: [] }],
[DeployContract, { kind: 'struct', fields: [['code', ['u8']]] }],
[FunctionCall, { kind: 'struct', fields: [['methodName', 'string'], ['args', ['u8']], ['gas', 'u64'], ['deposit', 'u128']] }],
[Transfer, { kind: 'struct', fields: [['deposit', 'u128']] }],
[Stake, { kind: 'struct', fields: [['stake', 'u128'], ['publicKey', PublicKey]] }],
[AddKey, { kind: 'struct', fields: [['publicKey', PublicKey], ['accessKey', AccessKey]] }],
[DeleteKey, { kind: 'struct', fields: [['publicKey', PublicKey]] }],
[DeleteAccount, { kind: 'struct', fields: [['beneficiaryId', 'string']] }],
[DeployContract, { kind: 'struct', fields: [
['code', ['u8']]
]}],
[FunctionCall, { kind: 'struct', fields: [
['methodName', 'string'],
['args', ['u8']],
['gas', 'u64'],
['deposit', 'u128']
]}],
[Transfer, { kind: 'struct', fields: [
['deposit', 'u128']
]}],
[Stake, { kind: 'struct', fields: [
['stake', 'u128'],
['publicKey', PublicKey]
]}],
[AddKey, { kind: 'struct', fields: [
['publicKey', PublicKey],
['accessKey', AccessKey]
]}],
[DeleteKey, { kind: 'struct', fields: [
['publicKey', PublicKey]
]}],
[DeleteAccount, { kind: 'struct', fields: [
['beneficiaryId', 'string']
]}],
]);

export async function signTransaction(receiverId: string, nonce: number, actions: Action[], blockHash: Uint8Array, signer: Signer, accountId?: string, networkId?: string): Promise<[Uint8Array, SignedTransaction]> {
Expand Down

0 comments on commit ce23775

Please sign in to comment.