@orderly.network/core 0.1.27-alpha.26 → 0.1.27-alpha.28

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.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import EventEmitter from 'eventemitter3';
2
2
  export { default as EventEmitter } from 'eventemitter3';
3
- import { API, AccountStatusEnum } from '@orderly.network/types';
3
+ import { definedTypes, API, AccountStatusEnum } from '@orderly.network/types';
4
4
  import { parseUnits, TransactionResponse, ethers } from 'ethers';
5
5
 
6
6
  interface OrderlyKeyPair {
@@ -179,6 +179,236 @@ declare namespace utils {
179
179
 
180
180
  declare const getMockSigner: (secretKey?: string) => BaseSigner;
181
181
  declare const getDefaultSigner: () => BaseSigner;
182
+ /**
183
+ * generate `registerAccount` data and to be signed message structure
184
+ */
185
+ declare function generateRegisterAccountMessage(inputs: {
186
+ chainId: number;
187
+ registrationNonce: number;
188
+ brokerId: string;
189
+ }): readonly [{
190
+ brokerId: string;
191
+ chainId: number;
192
+ timestamp: number;
193
+ registrationNonce: number;
194
+ }, {
195
+ domain: {
196
+ name: string;
197
+ version: string;
198
+ chainId: number;
199
+ verifyingContract: string;
200
+ };
201
+ message: {
202
+ brokerId: string;
203
+ chainId: number;
204
+ timestamp: number;
205
+ registrationNonce: number;
206
+ };
207
+ primaryType: string;
208
+ types: {
209
+ EIP712Domain: readonly [{
210
+ readonly name: "name";
211
+ readonly type: "string";
212
+ }, {
213
+ readonly name: "version";
214
+ readonly type: "string";
215
+ }, {
216
+ readonly name: "chainId";
217
+ readonly type: "uint256";
218
+ }, {
219
+ readonly name: "verifyingContract";
220
+ readonly type: "address";
221
+ }];
222
+ Registration: readonly [{
223
+ readonly name: "brokerId";
224
+ readonly type: "string";
225
+ }, {
226
+ readonly name: "chainId";
227
+ readonly type: "uint256";
228
+ }, {
229
+ readonly name: "timestamp";
230
+ readonly type: "uint64";
231
+ }, {
232
+ readonly name: "registrationNonce";
233
+ readonly type: "uint256";
234
+ }];
235
+ };
236
+ }];
237
+ /**
238
+ * generate `addOrderlyKey` data and to be signed message structure
239
+ */
240
+ declare function generateAddOrderlyKeyMessage(inputs: {
241
+ publicKey: string;
242
+ chainId: number;
243
+ brokerId: string;
244
+ primaryType: keyof typeof definedTypes;
245
+ expiration: number;
246
+ }): readonly [{
247
+ brokerId: string;
248
+ orderlyKey: string;
249
+ scope: string;
250
+ chainId: number;
251
+ timestamp: number;
252
+ expiration: number;
253
+ }, {
254
+ domain: {
255
+ name: string;
256
+ version: string;
257
+ chainId: number;
258
+ verifyingContract: string;
259
+ };
260
+ message: {
261
+ brokerId: string;
262
+ orderlyKey: string;
263
+ scope: string;
264
+ chainId: number;
265
+ timestamp: number;
266
+ expiration: number;
267
+ };
268
+ primaryType: "Registration" | "EIP712Domain" | "Withdraw" | "AddOrderlyKey" | "SettlePnl";
269
+ types: {
270
+ [x: string]: readonly [{
271
+ readonly name: "name";
272
+ readonly type: "string";
273
+ }, {
274
+ readonly name: "version";
275
+ readonly type: "string";
276
+ }, {
277
+ readonly name: "chainId";
278
+ readonly type: "uint256";
279
+ }, {
280
+ readonly name: "verifyingContract";
281
+ readonly type: "address";
282
+ }] | readonly [{
283
+ readonly name: "brokerId";
284
+ readonly type: "string";
285
+ }, {
286
+ readonly name: "chainId";
287
+ readonly type: "uint256";
288
+ }, {
289
+ readonly name: "timestamp";
290
+ readonly type: "uint64";
291
+ }, {
292
+ readonly name: "registrationNonce";
293
+ readonly type: "uint256";
294
+ }] | readonly [{
295
+ readonly name: "brokerId";
296
+ readonly type: "string";
297
+ }, {
298
+ readonly name: "chainId";
299
+ readonly type: "uint256";
300
+ }, {
301
+ readonly name: "receiver";
302
+ readonly type: "address";
303
+ }, {
304
+ readonly name: "token";
305
+ readonly type: "string";
306
+ }, {
307
+ readonly name: "amount";
308
+ readonly type: "uint256";
309
+ }, {
310
+ readonly name: "withdrawNonce";
311
+ readonly type: "uint64";
312
+ }, {
313
+ readonly name: "timestamp";
314
+ readonly type: "uint64";
315
+ }] | readonly [{
316
+ readonly name: "brokerId";
317
+ readonly type: "string";
318
+ }, {
319
+ readonly name: "chainId";
320
+ readonly type: "uint256";
321
+ }, {
322
+ readonly name: "orderlyKey";
323
+ readonly type: "string";
324
+ }, {
325
+ readonly name: "scope";
326
+ readonly type: "string";
327
+ }, {
328
+ readonly name: "timestamp";
329
+ readonly type: "uint64";
330
+ }, {
331
+ readonly name: "expiration";
332
+ readonly type: "uint64";
333
+ }] | readonly [{
334
+ readonly name: "brokerId";
335
+ readonly type: "string";
336
+ }, {
337
+ readonly name: "chainId";
338
+ readonly type: "uint256";
339
+ }, {
340
+ readonly name: "settleNonce";
341
+ readonly type: "uint64";
342
+ }, {
343
+ readonly name: "timestamp";
344
+ readonly type: "uint64";
345
+ }];
346
+ EIP712Domain: readonly [{
347
+ readonly name: "name";
348
+ readonly type: "string";
349
+ }, {
350
+ readonly name: "version";
351
+ readonly type: "string";
352
+ }, {
353
+ readonly name: "chainId";
354
+ readonly type: "uint256";
355
+ }, {
356
+ readonly name: "verifyingContract";
357
+ readonly type: "address";
358
+ }];
359
+ };
360
+ }];
361
+ /**
362
+ * generate `settle` data and to be signed message structure
363
+ */
364
+ declare function generateSettleMessage(inputs: {
365
+ chainId: number;
366
+ brokerId: string;
367
+ settlePnlNonce: string;
368
+ domain: SignatureDomain;
369
+ }): readonly [{
370
+ brokerId: string;
371
+ chainId: number;
372
+ timestamp: number;
373
+ settleNonce: string;
374
+ }, {
375
+ domain: SignatureDomain;
376
+ message: {
377
+ brokerId: string;
378
+ chainId: number;
379
+ timestamp: number;
380
+ settleNonce: string;
381
+ };
382
+ primaryType: string;
383
+ types: {
384
+ EIP712Domain: readonly [{
385
+ readonly name: "name";
386
+ readonly type: "string";
387
+ }, {
388
+ readonly name: "version";
389
+ readonly type: "string";
390
+ }, {
391
+ readonly name: "chainId";
392
+ readonly type: "uint256";
393
+ }, {
394
+ readonly name: "verifyingContract";
395
+ readonly type: "address";
396
+ }];
397
+ SettlePnl: readonly [{
398
+ readonly name: "brokerId";
399
+ readonly type: "string";
400
+ }, {
401
+ readonly name: "chainId";
402
+ readonly type: "uint256";
403
+ }, {
404
+ readonly name: "settleNonce";
405
+ readonly type: "uint64";
406
+ }, {
407
+ readonly name: "timestamp";
408
+ readonly type: "uint64";
409
+ }];
410
+ };
411
+ }];
182
412
 
183
413
  /**
184
414
  * Orderly contracts information
@@ -395,7 +625,7 @@ declare class Assets {
395
625
  withdraw(inputs: {
396
626
  chainId: number;
397
627
  token: string;
398
- amount: number;
628
+ amount: string | number;
399
629
  allowCrossChainWithdraw: boolean;
400
630
  }): Promise<any>;
401
631
  private _generateWithdrawMessage;
@@ -553,4 +783,4 @@ declare class EtherAdapter implements IWalletAdapter {
553
783
  getContract(address: string, abi: any): ethers.Contract;
554
784
  }
555
785
 
556
- export { Account, AccountState, BaseConfigStore, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, ConfigKey, ConfigStore, DefaultConfigStore, EtherAdapter, IContract, LocalStorageStore, MemoryConfigStore, MessageFactor, MockKeyStore, OrderlyKeyPair, OrderlyKeyStore, SignedMessagePayload, Signer, SimpleDI, IWalletAdapter as WalletAdapter, WalletAdapterOptions, getDefaultSigner, getMockSigner, getWalletAdapterFunc, utils };
786
+ export { Account, AccountState, BaseConfigStore, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, ConfigKey, ConfigStore, DefaultConfigStore, EtherAdapter, IContract, LocalStorageStore, MemoryConfigStore, MessageFactor, MockKeyStore, OrderlyKeyPair, OrderlyKeyStore, SignedMessagePayload, Signer, SimpleDI, IWalletAdapter as WalletAdapter, WalletAdapterOptions, generateAddOrderlyKeyMessage, generateRegisterAccountMessage, generateSettleMessage, getDefaultSigner, getMockSigner, getWalletAdapterFunc, utils };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import EventEmitter from 'eventemitter3';
2
2
  export { default as EventEmitter } from 'eventemitter3';
3
- import { API, AccountStatusEnum } from '@orderly.network/types';
3
+ import { definedTypes, API, AccountStatusEnum } from '@orderly.network/types';
4
4
  import { parseUnits, TransactionResponse, ethers } from 'ethers';
5
5
 
6
6
  interface OrderlyKeyPair {
@@ -179,6 +179,236 @@ declare namespace utils {
179
179
 
180
180
  declare const getMockSigner: (secretKey?: string) => BaseSigner;
181
181
  declare const getDefaultSigner: () => BaseSigner;
182
+ /**
183
+ * generate `registerAccount` data and to be signed message structure
184
+ */
185
+ declare function generateRegisterAccountMessage(inputs: {
186
+ chainId: number;
187
+ registrationNonce: number;
188
+ brokerId: string;
189
+ }): readonly [{
190
+ brokerId: string;
191
+ chainId: number;
192
+ timestamp: number;
193
+ registrationNonce: number;
194
+ }, {
195
+ domain: {
196
+ name: string;
197
+ version: string;
198
+ chainId: number;
199
+ verifyingContract: string;
200
+ };
201
+ message: {
202
+ brokerId: string;
203
+ chainId: number;
204
+ timestamp: number;
205
+ registrationNonce: number;
206
+ };
207
+ primaryType: string;
208
+ types: {
209
+ EIP712Domain: readonly [{
210
+ readonly name: "name";
211
+ readonly type: "string";
212
+ }, {
213
+ readonly name: "version";
214
+ readonly type: "string";
215
+ }, {
216
+ readonly name: "chainId";
217
+ readonly type: "uint256";
218
+ }, {
219
+ readonly name: "verifyingContract";
220
+ readonly type: "address";
221
+ }];
222
+ Registration: readonly [{
223
+ readonly name: "brokerId";
224
+ readonly type: "string";
225
+ }, {
226
+ readonly name: "chainId";
227
+ readonly type: "uint256";
228
+ }, {
229
+ readonly name: "timestamp";
230
+ readonly type: "uint64";
231
+ }, {
232
+ readonly name: "registrationNonce";
233
+ readonly type: "uint256";
234
+ }];
235
+ };
236
+ }];
237
+ /**
238
+ * generate `addOrderlyKey` data and to be signed message structure
239
+ */
240
+ declare function generateAddOrderlyKeyMessage(inputs: {
241
+ publicKey: string;
242
+ chainId: number;
243
+ brokerId: string;
244
+ primaryType: keyof typeof definedTypes;
245
+ expiration: number;
246
+ }): readonly [{
247
+ brokerId: string;
248
+ orderlyKey: string;
249
+ scope: string;
250
+ chainId: number;
251
+ timestamp: number;
252
+ expiration: number;
253
+ }, {
254
+ domain: {
255
+ name: string;
256
+ version: string;
257
+ chainId: number;
258
+ verifyingContract: string;
259
+ };
260
+ message: {
261
+ brokerId: string;
262
+ orderlyKey: string;
263
+ scope: string;
264
+ chainId: number;
265
+ timestamp: number;
266
+ expiration: number;
267
+ };
268
+ primaryType: "Registration" | "EIP712Domain" | "Withdraw" | "AddOrderlyKey" | "SettlePnl";
269
+ types: {
270
+ [x: string]: readonly [{
271
+ readonly name: "name";
272
+ readonly type: "string";
273
+ }, {
274
+ readonly name: "version";
275
+ readonly type: "string";
276
+ }, {
277
+ readonly name: "chainId";
278
+ readonly type: "uint256";
279
+ }, {
280
+ readonly name: "verifyingContract";
281
+ readonly type: "address";
282
+ }] | readonly [{
283
+ readonly name: "brokerId";
284
+ readonly type: "string";
285
+ }, {
286
+ readonly name: "chainId";
287
+ readonly type: "uint256";
288
+ }, {
289
+ readonly name: "timestamp";
290
+ readonly type: "uint64";
291
+ }, {
292
+ readonly name: "registrationNonce";
293
+ readonly type: "uint256";
294
+ }] | readonly [{
295
+ readonly name: "brokerId";
296
+ readonly type: "string";
297
+ }, {
298
+ readonly name: "chainId";
299
+ readonly type: "uint256";
300
+ }, {
301
+ readonly name: "receiver";
302
+ readonly type: "address";
303
+ }, {
304
+ readonly name: "token";
305
+ readonly type: "string";
306
+ }, {
307
+ readonly name: "amount";
308
+ readonly type: "uint256";
309
+ }, {
310
+ readonly name: "withdrawNonce";
311
+ readonly type: "uint64";
312
+ }, {
313
+ readonly name: "timestamp";
314
+ readonly type: "uint64";
315
+ }] | readonly [{
316
+ readonly name: "brokerId";
317
+ readonly type: "string";
318
+ }, {
319
+ readonly name: "chainId";
320
+ readonly type: "uint256";
321
+ }, {
322
+ readonly name: "orderlyKey";
323
+ readonly type: "string";
324
+ }, {
325
+ readonly name: "scope";
326
+ readonly type: "string";
327
+ }, {
328
+ readonly name: "timestamp";
329
+ readonly type: "uint64";
330
+ }, {
331
+ readonly name: "expiration";
332
+ readonly type: "uint64";
333
+ }] | readonly [{
334
+ readonly name: "brokerId";
335
+ readonly type: "string";
336
+ }, {
337
+ readonly name: "chainId";
338
+ readonly type: "uint256";
339
+ }, {
340
+ readonly name: "settleNonce";
341
+ readonly type: "uint64";
342
+ }, {
343
+ readonly name: "timestamp";
344
+ readonly type: "uint64";
345
+ }];
346
+ EIP712Domain: readonly [{
347
+ readonly name: "name";
348
+ readonly type: "string";
349
+ }, {
350
+ readonly name: "version";
351
+ readonly type: "string";
352
+ }, {
353
+ readonly name: "chainId";
354
+ readonly type: "uint256";
355
+ }, {
356
+ readonly name: "verifyingContract";
357
+ readonly type: "address";
358
+ }];
359
+ };
360
+ }];
361
+ /**
362
+ * generate `settle` data and to be signed message structure
363
+ */
364
+ declare function generateSettleMessage(inputs: {
365
+ chainId: number;
366
+ brokerId: string;
367
+ settlePnlNonce: string;
368
+ domain: SignatureDomain;
369
+ }): readonly [{
370
+ brokerId: string;
371
+ chainId: number;
372
+ timestamp: number;
373
+ settleNonce: string;
374
+ }, {
375
+ domain: SignatureDomain;
376
+ message: {
377
+ brokerId: string;
378
+ chainId: number;
379
+ timestamp: number;
380
+ settleNonce: string;
381
+ };
382
+ primaryType: string;
383
+ types: {
384
+ EIP712Domain: readonly [{
385
+ readonly name: "name";
386
+ readonly type: "string";
387
+ }, {
388
+ readonly name: "version";
389
+ readonly type: "string";
390
+ }, {
391
+ readonly name: "chainId";
392
+ readonly type: "uint256";
393
+ }, {
394
+ readonly name: "verifyingContract";
395
+ readonly type: "address";
396
+ }];
397
+ SettlePnl: readonly [{
398
+ readonly name: "brokerId";
399
+ readonly type: "string";
400
+ }, {
401
+ readonly name: "chainId";
402
+ readonly type: "uint256";
403
+ }, {
404
+ readonly name: "settleNonce";
405
+ readonly type: "uint64";
406
+ }, {
407
+ readonly name: "timestamp";
408
+ readonly type: "uint64";
409
+ }];
410
+ };
411
+ }];
182
412
 
183
413
  /**
184
414
  * Orderly contracts information
@@ -395,7 +625,7 @@ declare class Assets {
395
625
  withdraw(inputs: {
396
626
  chainId: number;
397
627
  token: string;
398
- amount: number;
628
+ amount: string | number;
399
629
  allowCrossChainWithdraw: boolean;
400
630
  }): Promise<any>;
401
631
  private _generateWithdrawMessage;
@@ -553,4 +783,4 @@ declare class EtherAdapter implements IWalletAdapter {
553
783
  getContract(address: string, abi: any): ethers.Contract;
554
784
  }
555
785
 
556
- export { Account, AccountState, BaseConfigStore, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, ConfigKey, ConfigStore, DefaultConfigStore, EtherAdapter, IContract, LocalStorageStore, MemoryConfigStore, MessageFactor, MockKeyStore, OrderlyKeyPair, OrderlyKeyStore, SignedMessagePayload, Signer, SimpleDI, IWalletAdapter as WalletAdapter, WalletAdapterOptions, getDefaultSigner, getMockSigner, getWalletAdapterFunc, utils };
786
+ export { Account, AccountState, BaseConfigStore, BaseContract as BaseContractManager, BaseKeyStore, BaseOrderlyKeyPair, BaseSigner, ConfigKey, ConfigStore, DefaultConfigStore, EtherAdapter, IContract, LocalStorageStore, MemoryConfigStore, MessageFactor, MockKeyStore, OrderlyKeyPair, OrderlyKeyStore, SignedMessagePayload, Signer, SimpleDI, IWalletAdapter as WalletAdapter, WalletAdapterOptions, generateAddOrderlyKeyMessage, generateRegisterAccountMessage, generateSettleMessage, getDefaultSigner, getMockSigner, getWalletAdapterFunc, utils };