Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix delegate schema #1314

Merged
merged 4 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/happy-onions-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@near-js/transactions": patch
---

Fixed delegateAction Schema
2 changes: 1 addition & 1 deletion packages/transactions/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ export const SCHEMA = new class BorshSchema {
struct: {
senderId: 'string',
receiverId: 'string',
nonce: 'u64',
actions: { array: { type: this.ClassicActions } },
nonce: 'u64',
maxBlockHeight: 'u64',
publicKey: this.PublicKey,
}
Expand Down
8 changes: 8 additions & 0 deletions packages/transactions/test/serialize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ test('serialize object', async () => {
expect(new_value.q).toEqual([1, 2, 3]);
});

test('deserialize delegate', async () => {
const serialized = [8, 16, 0, 0, 0, 116, 104, 101, 45, 117, 115, 101, 114, 46, 116, 101, 115, 116, 110, 101, 116, 27, 0, 0, 0, 104, 101, 108, 108, 111, 46, 110, 101, 97, 114, 45, 101, 120, 97, 109, 112, 108, 101, 115, 46, 116, 101, 115, 116, 110, 101, 116, 1, 0, 0, 0, 2, 12, 0, 0, 0, 115, 101, 116, 95, 103, 114, 101, 101, 116, 105, 110, 103, 20, 0, 0, 0, 123, 34, 103, 114, 101, 101, 116, 105, 110, 103, 34, 58, 34, 72, 101, 108, 108, 111, 34, 125, 0, 224, 87, 235, 72, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 9, 120, 166, 131, 144, 0, 0, 61, 158, 123, 9, 0, 0, 0, 0, 0, 154, 156, 80, 116, 108, 65, 42, 39, 47, 253, 146, 109, 67, 106, 83, 230, 57, 183, 195, 122, 150, 6, 246, 220, 173, 35, 120, 139, 167, 94, 183, 29, 0, 41, 98, 10, 45, 51, 177, 89, 159, 190, 247, 41, 255, 243, 17, 186, 140, 168, 139, 9, 81, 33, 8, 74, 73, 85, 254, 127, 62, 54, 193, 60, 50, 235, 49, 13, 37, 152, 94, 172, 24, 198, 220, 119, 148, 99, 89, 19, 187, 251, 80, 76, 230, 77, 28, 80, 140, 133, 81, 139, 159, 62, 245, 167, 4];
const { signedDelegate: { delegateAction } } = deserialize(SCHEMA.Action, serialized);
expect(delegateAction.senderId).toEqual('the-user.testnet');
expect(delegateAction.receiverId).toEqual('hello.near-examples.testnet');
expect(String(delegateAction.nonce)).toEqual('158895108000003');
});

test('serialize and sign multi-action tx', async () => {
const keyStore = new InMemoryKeyStore();
const keyPair = KeyPair.fromString('ed25519:2wyRcSwSuHtRVmkMCGjPwnzZmQLeXLzLLyED1NDMt4BjnKgQL6tF85yBx6Jr26D2dUNeC716RBoTxntVHsegogYw');
Expand Down
Loading