Skip to content

Commit

Permalink
sendNote works too
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Dec 1, 2024
1 parent 467c2a6 commit 564bddd
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export default {
unused_index_17: null,
unused_index_18: null,
unused_index_19: null,
send_node: 'SendNoteArgs',
send_note: 'SendNoteArgs',
unused_index_21: null,
unused_index_22: null,
unused_index_23: null,
Expand Down
20 changes: 20 additions & 0 deletions packages/worker-api/src/integriteeWorker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,26 @@ describe('worker', () => {
expect(status.isInSidechainBlock).toBeTruthy();
});
});

// race condition so skipped
describe.only('send note should work', () => {
it('send note included', async () => {
const shard = network.shard;
const result = await worker.trustedSendNote(
alice,
shard,
network.mrenclave,
alice.address,
charlie.address,
"Hoi"
);
console.log('send note', JSON.stringify(result));
expect(result).toBeDefined();
const status = worker.createType('TrustedOperationStatus', result.status);
expect(status.isInSidechainBlock).toBeTruthy();
});
});

// race condition so skipped
describe.skip('balance transfer should work', () => {
it('should return value', async () => {
Expand Down
17 changes: 17 additions & 0 deletions packages/worker-api/src/integriteeWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,23 @@ export class IntegriteeWorker extends Worker {
return this.sendTrustedCall(signed, shardT);
}

public async trustedSendNote(
account: AddressOrPair,
shard: string,
mrenclave: string,
from: String,
to: String,
note: string,
signerOptions?: TrustedSignerOptions,
): Promise<TrustedCallResult> {
const nonce = signerOptions?.nonce ?? await this.getNonce(account, shard, signerOptions)
const shardT = this.createType('ShardIdentifier', bs58.decode(shard));
const params = this.createType('SendNoteArgs', [from, to, note])
const call = createTrustedCall(this, ['send_note', 'SendNoteArgs'], params);
const signed = await signTrustedCall(this, call, account, shardT, mrenclave, nonce, signerOptions);
return this.sendTrustedCall(signed, shardT);
}

public async guessTheNumber(
account: AddressOrPair,
shard: string,
Expand Down

0 comments on commit 564bddd

Please sign in to comment.