@thesingularitynetwork/darkswap-sdk 0.1.15 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ethers, AbiCoder, ripemd160, hexlify } from 'ethers';
2
+ import cryptoJs from 'crypto-js';
2
3
  import { Schnorr } from '@aztec/foundation/crypto';
3
4
  import { Fr, Fq } from '@aztec/foundation/fields';
4
5
  import { UltraHonkBackend } from '@aztec/bb.js';
@@ -731,47 +732,41 @@ function mimc_bn254(array) {
731
732
  }
732
733
 
733
734
  let getRandomValues;
734
- if (typeof window !== 'undefined' && window.crypto && window.crypto.getRandomValues) {
735
- getRandomValues = (buf) => window.crypto.getRandomValues(buf);
736
- }
737
- else {
738
- const nodeCrypto = require('crypto');
739
- getRandomValues = (buf) => {
740
- const randomBytes = nodeCrypto.randomBytes(buf.length);
741
- buf.set(randomBytes);
742
- return buf;
743
- };
744
- }
735
+ getRandomValues = (buf) => {
736
+ const randomBytes = cryptoJs.randomBytes(buf.length);
737
+ buf.set(randomBytes);
738
+ return buf;
739
+ };
745
740
  const DOMAIN_NOTE = 2n;
746
741
  const DOMAIN_ORDER_NOTE = 3n;
747
742
  const EMPTY_NOTE = {
743
+ address: '0x0000000000000000000000000000000000000000',
748
744
  rho: 0n,
749
745
  note: 0n,
750
746
  amount: 0n,
751
- asset: '0x0000000000000000000000000000000000000000'
747
+ asset: '0x0000000000000000000000000000000000000000',
752
748
  };
753
749
  function createNote(address, asset, amount, fuzkPubKey) {
754
750
  const rho = generateRho();
755
751
  const footer = getNoteFooter(rho, fuzkPubKey);
756
752
  const addressMod = encodeAddress(address);
757
753
  const assetMod = encodeAddress(asset);
758
- const note = mimc_bn254([
759
- DOMAIN_NOTE,
760
- addressMod,
761
- assetMod,
762
- amount,
763
- footer
764
- ]);
754
+ const note = mimc_bn254([DOMAIN_NOTE, addressMod, assetMod, amount, footer]);
765
755
  return {
756
+ address,
766
757
  rho,
767
758
  note,
768
759
  asset,
769
760
  amount,
770
- footer
761
+ footer,
771
762
  };
772
763
  }
773
764
  function getNoteFooter(rho, publicKey) {
774
- return mimc_bn254([mimc_bn254([BigInt(rho)]), BigInt(publicKey[0].toString()), BigInt(publicKey[1].toString())]);
765
+ return mimc_bn254([
766
+ mimc_bn254([BigInt(rho)]),
767
+ BigInt(publicKey[0].toString()),
768
+ BigInt(publicKey[1].toString()),
769
+ ]);
775
770
  }
776
771
  function generateRho() {
777
772
  const securityLevel = 128;
@@ -786,7 +781,11 @@ function generateRho() {
786
781
  return rho;
787
782
  }
788
783
  function calcNullifier(rho, fuzkPubKey) {
789
- return mimc_bn254([rho, BigInt(fuzkPubKey[0].toString()), BigInt(fuzkPubKey[1].toString())]);
784
+ return mimc_bn254([
785
+ rho,
786
+ BigInt(fuzkPubKey[0].toString()),
787
+ BigInt(fuzkPubKey[1].toString()),
788
+ ]);
790
789
  }
791
790
  function createOrderNoteExt(address, asset, amount, feeRatio, fuzkPubKey) {
792
791
  const rho = generateRho();
@@ -799,14 +798,15 @@ function createOrderNoteExt(address, asset, amount, feeRatio, fuzkPubKey) {
799
798
  assetMod,
800
799
  amount,
801
800
  feeRatio,
802
- footer
801
+ footer,
803
802
  ]);
804
803
  return {
804
+ address,
805
805
  rho,
806
806
  note: noteCommitment,
807
807
  asset,
808
808
  amount,
809
- feeRatio
809
+ feeRatio,
810
810
  };
811
811
  }
812
812
 
@@ -7419,6 +7419,7 @@ function deserializeDarkSwapMessage(serializedMessage) {
7419
7419
  return {
7420
7420
  address: message.address,
7421
7421
  orderNote: {
7422
+ address: message.orderNote.address,
7422
7423
  rho: BigInt(message.orderNote.rho),
7423
7424
  amount: BigInt(message.orderNote.amount),
7424
7425
  asset: message.orderNote.asset,
@@ -7427,6 +7428,7 @@ function deserializeDarkSwapMessage(serializedMessage) {
7427
7428
  },
7428
7429
  feeAmount: BigInt(message.feeAmount),
7429
7430
  inNote: {
7431
+ address: message.inNote.address,
7430
7432
  rho: BigInt(message.inNote.rho),
7431
7433
  amount: BigInt(message.inNote.amount),
7432
7434
  asset: message.inNote.asset,
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var ethers = require('ethers');
4
+ var cryptoJs = require('crypto-js');
4
5
  var crypto = require('@aztec/foundation/crypto');
5
6
  var fields = require('@aztec/foundation/fields');
6
7
  var bb_js = require('@aztec/bb.js');
@@ -733,47 +734,41 @@ function mimc_bn254(array) {
733
734
  }
734
735
 
735
736
  let getRandomValues;
736
- if (typeof window !== 'undefined' && window.crypto && window.crypto.getRandomValues) {
737
- getRandomValues = (buf) => window.crypto.getRandomValues(buf);
738
- }
739
- else {
740
- const nodeCrypto = require('crypto');
741
- getRandomValues = (buf) => {
742
- const randomBytes = nodeCrypto.randomBytes(buf.length);
743
- buf.set(randomBytes);
744
- return buf;
745
- };
746
- }
737
+ getRandomValues = (buf) => {
738
+ const randomBytes = cryptoJs.randomBytes(buf.length);
739
+ buf.set(randomBytes);
740
+ return buf;
741
+ };
747
742
  const DOMAIN_NOTE = 2n;
748
743
  const DOMAIN_ORDER_NOTE = 3n;
749
744
  const EMPTY_NOTE = {
745
+ address: '0x0000000000000000000000000000000000000000',
750
746
  rho: 0n,
751
747
  note: 0n,
752
748
  amount: 0n,
753
- asset: '0x0000000000000000000000000000000000000000'
749
+ asset: '0x0000000000000000000000000000000000000000',
754
750
  };
755
751
  function createNote(address, asset, amount, fuzkPubKey) {
756
752
  const rho = generateRho();
757
753
  const footer = getNoteFooter(rho, fuzkPubKey);
758
754
  const addressMod = encodeAddress(address);
759
755
  const assetMod = encodeAddress(asset);
760
- const note = mimc_bn254([
761
- DOMAIN_NOTE,
762
- addressMod,
763
- assetMod,
764
- amount,
765
- footer
766
- ]);
756
+ const note = mimc_bn254([DOMAIN_NOTE, addressMod, assetMod, amount, footer]);
767
757
  return {
758
+ address,
768
759
  rho,
769
760
  note,
770
761
  asset,
771
762
  amount,
772
- footer
763
+ footer,
773
764
  };
774
765
  }
775
766
  function getNoteFooter(rho, publicKey) {
776
- return mimc_bn254([mimc_bn254([BigInt(rho)]), BigInt(publicKey[0].toString()), BigInt(publicKey[1].toString())]);
767
+ return mimc_bn254([
768
+ mimc_bn254([BigInt(rho)]),
769
+ BigInt(publicKey[0].toString()),
770
+ BigInt(publicKey[1].toString()),
771
+ ]);
777
772
  }
778
773
  function generateRho() {
779
774
  const securityLevel = 128;
@@ -788,7 +783,11 @@ function generateRho() {
788
783
  return rho;
789
784
  }
790
785
  function calcNullifier(rho, fuzkPubKey) {
791
- return mimc_bn254([rho, BigInt(fuzkPubKey[0].toString()), BigInt(fuzkPubKey[1].toString())]);
786
+ return mimc_bn254([
787
+ rho,
788
+ BigInt(fuzkPubKey[0].toString()),
789
+ BigInt(fuzkPubKey[1].toString()),
790
+ ]);
792
791
  }
793
792
  function createOrderNoteExt(address, asset, amount, feeRatio, fuzkPubKey) {
794
793
  const rho = generateRho();
@@ -801,14 +800,15 @@ function createOrderNoteExt(address, asset, amount, feeRatio, fuzkPubKey) {
801
800
  assetMod,
802
801
  amount,
803
802
  feeRatio,
804
- footer
803
+ footer,
805
804
  ]);
806
805
  return {
806
+ address,
807
807
  rho,
808
808
  note: noteCommitment,
809
809
  asset,
810
810
  amount,
811
- feeRatio
811
+ feeRatio,
812
812
  };
813
813
  }
814
814
 
@@ -7421,6 +7421,7 @@ function deserializeDarkSwapMessage(serializedMessage) {
7421
7421
  return {
7422
7422
  address: message.address,
7423
7423
  orderNote: {
7424
+ address: message.orderNote.address,
7424
7425
  rho: BigInt(message.orderNote.rho),
7425
7426
  amount: BigInt(message.orderNote.amount),
7426
7427
  asset: message.orderNote.asset,
@@ -7429,6 +7430,7 @@ function deserializeDarkSwapMessage(serializedMessage) {
7429
7430
  },
7430
7431
  feeAmount: BigInt(message.feeAmount),
7431
7432
  inNote: {
7433
+ address: message.inNote.address,
7432
7434
  rho: BigInt(message.inNote.rho),
7433
7435
  amount: BigInt(message.inNote.amount),
7434
7436
  asset: message.inNote.asset,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,5 +1,5 @@
1
- import { Fr } from "@aztec/foundation/fields";
2
- import { DarkSwapNote, DarkSwapNoteExt, DarkSwapOrderNote } from "../types.js";
1
+ import { Fr } from '@aztec/foundation/fields';
2
+ import { DarkSwapNote, DarkSwapNoteExt, DarkSwapOrderNote } from '../types.js';
3
3
  export declare const DOMAIN_NOTE = 2n;
4
4
  export declare const DOMAIN_ORDER_NOTE = 3n;
5
5
  export declare const EMPTY_NOTE: DarkSwapNote;
@@ -28,6 +28,7 @@ export type DarkSwapOrderNoteExt = DarkSwapOrderNote & {
28
28
  nullifier: string;
29
29
  };
30
30
  export type CreateNoteParam = {
31
+ address: string;
31
32
  rho: bigint;
32
33
  amount: bigint;
33
34
  asset: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thesingularitynetwork/darkswap-sdk",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "description": "DarkSwap SDK for browser and Node.js",
5
5
  "type": "module",
6
6
  "types": "dist/types/src/index.d.ts",
@@ -49,6 +49,7 @@
49
49
  "@noir-lang/noir_js": "^1.0.0-beta.3",
50
50
  "@noir-lang/noir_wasm": "^1.0.0-beta.3",
51
51
  "@noir-lang/types": "^1.0.0-beta.3",
52
+ "crypto-js": "^4.2.0",
52
53
  "ethers": "^6.14.3"
53
54
  }
54
55
  }
@@ -1,109 +1,110 @@
1
- import { Fr } from "@aztec/foundation/fields";
2
- import { hexlify } from "ethers";
3
- import { DarkSwapNote, DarkSwapNoteExt, DarkSwapOrderNote } from "../types.js";
4
- import { P } from "../utils/constants.js";
5
- import { encodeAddress } from "../utils/encoders.js";
6
- import { mimc_bn254 } from "../utils/mimc.js";
1
+ import { Fr } from '@aztec/foundation/fields'
2
+ import { hexlify } from 'ethers'
3
+ import { DarkSwapNote, DarkSwapNoteExt, DarkSwapOrderNote } from '../types.js'
4
+ import { P } from '../utils/constants.js'
5
+ import { encodeAddress } from '../utils/encoders.js'
6
+ import { mimc_bn254 } from '../utils/mimc.js'
7
+ import cryptoJs from 'crypto-js'
7
8
 
8
- let getRandomValues: (buf: Uint8Array) => Uint8Array;
9
+ let getRandomValues: (buf: Uint8Array) => Uint8Array
9
10
 
10
- if (typeof window !== 'undefined' && window.crypto && window.crypto.getRandomValues) {
11
- getRandomValues = (buf) => window.crypto.getRandomValues(buf);
12
- } else {
13
- const nodeCrypto = require('crypto');
14
- getRandomValues = (buf) => {
15
- const randomBytes = nodeCrypto.randomBytes(buf.length);
16
- buf.set(randomBytes);
17
- return buf;
18
- };
11
+ getRandomValues = (buf) => {
12
+ const randomBytes = cryptoJs.randomBytes(buf.length)
13
+ buf.set(randomBytes)
14
+ return buf
19
15
  }
20
16
 
21
- export const DOMAIN_NOTE = 2n;
22
- export const DOMAIN_ORDER_NOTE = 3n;
17
+ export const DOMAIN_NOTE = 2n
18
+ export const DOMAIN_ORDER_NOTE = 3n
23
19
 
24
20
  export const EMPTY_NOTE: DarkSwapNote = {
25
- rho: 0n,
26
- note: 0n,
27
- amount: 0n,
28
- asset: '0x0000000000000000000000000000000000000000'
21
+ address: '0x0000000000000000000000000000000000000000',
22
+ rho: 0n,
23
+ note: 0n,
24
+ amount: 0n,
25
+ asset: '0x0000000000000000000000000000000000000000',
29
26
  }
30
27
 
31
28
  export function createNote(
32
- address: string,
33
- asset: string,
34
- amount: bigint,
35
- fuzkPubKey: [Fr, Fr]
29
+ address: string,
30
+ asset: string,
31
+ amount: bigint,
32
+ fuzkPubKey: [Fr, Fr]
36
33
  ): DarkSwapNoteExt {
37
- const rho = generateRho();
38
- const footer = getNoteFooter(rho, fuzkPubKey)
34
+ const rho = generateRho()
35
+ const footer = getNoteFooter(rho, fuzkPubKey)
39
36
 
40
- const addressMod = encodeAddress(address);
41
- const assetMod = encodeAddress(asset);
42
- const note = mimc_bn254([
43
- DOMAIN_NOTE,
44
- addressMod,
45
- assetMod,
46
- amount,
47
- footer
48
- ]);
49
- return {
50
- rho,
51
- note,
52
- asset,
53
- amount,
54
- footer
55
- };
37
+ const addressMod = encodeAddress(address)
38
+ const assetMod = encodeAddress(asset)
39
+ const note = mimc_bn254([DOMAIN_NOTE, addressMod, assetMod, amount, footer])
40
+ return {
41
+ address,
42
+ rho,
43
+ note,
44
+ asset,
45
+ amount,
46
+ footer,
47
+ }
56
48
  }
57
49
 
58
50
  export function getNoteFooter(rho: bigint, publicKey: [Fr, Fr]): bigint {
59
- return mimc_bn254([mimc_bn254([BigInt(rho)]), BigInt(publicKey[0].toString()), BigInt(publicKey[1].toString())]);
51
+ return mimc_bn254([
52
+ mimc_bn254([BigInt(rho)]),
53
+ BigInt(publicKey[0].toString()),
54
+ BigInt(publicKey[1].toString()),
55
+ ])
60
56
  }
61
57
 
62
58
  function generateRho(): bigint {
63
- const securityLevel = 128;
64
- const primeByteLength = Math.ceil(P.toString(2).length / 8);
65
- const totalBytes = primeByteLength + Math.ceil(securityLevel / 8);
59
+ const securityLevel = 128
60
+ const primeByteLength = Math.ceil(P.toString(2).length / 8)
61
+ const totalBytes = primeByteLength + Math.ceil(securityLevel / 8)
66
62
 
67
- let rho = BigInt(0);
68
- do {
69
- let ab = new ArrayBuffer(totalBytes);
70
- let buf = new Uint8Array(ab);
71
- rho = BigInt(hexlify(getRandomValues(buf))) % P;
72
- } while (rho === BigInt(0));
63
+ let rho = BigInt(0)
64
+ do {
65
+ let ab = new ArrayBuffer(totalBytes)
66
+ let buf = new Uint8Array(ab)
67
+ rho = BigInt(hexlify(getRandomValues(buf))) % P
68
+ } while (rho === BigInt(0))
73
69
 
74
- return rho;
70
+ return rho
75
71
  }
76
72
 
77
73
  export function calcNullifier(rho: bigint, fuzkPubKey: [Fr, Fr]): bigint {
78
- return mimc_bn254([rho, BigInt(fuzkPubKey[0].toString()), BigInt(fuzkPubKey[1].toString())]);
74
+ return mimc_bn254([
75
+ rho,
76
+ BigInt(fuzkPubKey[0].toString()),
77
+ BigInt(fuzkPubKey[1].toString()),
78
+ ])
79
79
  }
80
80
 
81
81
  export function createOrderNoteExt(
82
- address: string,
83
- asset: string,
84
- amount: bigint,
85
- feeRatio: bigint,
86
- fuzkPubKey: [Fr, Fr]
82
+ address: string,
83
+ asset: string,
84
+ amount: bigint,
85
+ feeRatio: bigint,
86
+ fuzkPubKey: [Fr, Fr]
87
87
  ): DarkSwapOrderNote {
88
- const rho = generateRho();
89
- const footer = getNoteFooter(rho, fuzkPubKey)
88
+ const rho = generateRho()
89
+ const footer = getNoteFooter(rho, fuzkPubKey)
90
90
 
91
- const assetMod = encodeAddress(asset);
92
- const addressMod = encodeAddress(address);
93
- const noteCommitment = mimc_bn254([
94
- DOMAIN_ORDER_NOTE,
95
- addressMod,
96
- assetMod,
97
- amount,
98
- feeRatio,
99
- footer
100
- ]);
91
+ const assetMod = encodeAddress(asset)
92
+ const addressMod = encodeAddress(address)
93
+ const noteCommitment = mimc_bn254([
94
+ DOMAIN_ORDER_NOTE,
95
+ addressMod,
96
+ assetMod,
97
+ amount,
98
+ feeRatio,
99
+ footer,
100
+ ])
101
101
 
102
- return {
103
- rho,
104
- note: noteCommitment,
105
- asset,
106
- amount,
107
- feeRatio
108
- };
109
- }
102
+ return {
103
+ address,
104
+ rho,
105
+ note: noteCommitment,
106
+ asset,
107
+ amount,
108
+ feeRatio,
109
+ }
110
+ }
package/src/types.ts CHANGED
@@ -40,6 +40,7 @@ export type DarkSwapOrderNoteExt = DarkSwapOrderNote & {
40
40
  }
41
41
 
42
42
  export type CreateNoteParam = {
43
+ address: string,
43
44
  rho: bigint,
44
45
  amount: bigint,
45
46
  asset: string,
@@ -33,6 +33,7 @@ export function deserializeDarkSwapMessage(serializedMessage: string): DarkSwapM
33
33
  return {
34
34
  address: message.address,
35
35
  orderNote: {
36
+ address: message.orderNote.address,
36
37
  rho: BigInt(message.orderNote.rho),
37
38
  amount: BigInt(message.orderNote.amount),
38
39
  asset: message.orderNote.asset,
@@ -41,6 +42,7 @@ export function deserializeDarkSwapMessage(serializedMessage: string): DarkSwapM
41
42
  },
42
43
  feeAmount: BigInt(message.feeAmount),
43
44
  inNote: {
45
+ address: message.inNote.address,
44
46
  rho: BigInt(message.inNote.rho),
45
47
  amount: BigInt(message.inNote.amount),
46
48
  asset: message.inNote.asset,