dequanto 0.2.44 → 0.2.45

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.
Files changed (104) hide show
  1. package/lib/cjs/abi/coders/abstract-coder.js +18 -7
  2. package/lib/cjs/abi/coders/abstract-coder.js.map +1 -1
  3. package/lib/cjs/abi/fragments.js +24 -8
  4. package/lib/cjs/abi/fragments.js.map +1 -1
  5. package/lib/cjs/class/PackedRanges.js +6 -2
  6. package/lib/cjs/class/PackedRanges.js.map +1 -1
  7. package/lib/cjs/class/SubjectStream.js +3 -1
  8. package/lib/cjs/class/SubjectStream.js.map +1 -1
  9. package/lib/cjs/clients/WalletClient.js +3 -1
  10. package/lib/cjs/clients/WalletClient.js.map +1 -1
  11. package/lib/cjs/contracts/deploy/Deployments.js +1 -1
  12. package/lib/cjs/contracts/deploy/Deployments.js.map +1 -1
  13. package/lib/cjs/contracts/deploy/proxy/ProxyDeployment.js +3 -1
  14. package/lib/cjs/contracts/deploy/proxy/ProxyDeployment.js.map +1 -1
  15. package/lib/cjs/indexer/EventsIndexer.js +3 -1
  16. package/lib/cjs/indexer/EventsIndexer.js.map +1 -1
  17. package/lib/cjs/safe/GnosisSafeHandler.js +6 -1
  18. package/lib/cjs/safe/GnosisSafeHandler.js.map +1 -1
  19. package/lib/cjs/safe/transport/InMemoryServiceTransport.js +4 -4
  20. package/lib/cjs/safe/transport/InMemoryServiceTransport.js.map +1 -1
  21. package/lib/cjs/safe/transport/SafeServiceTransport.js.map +1 -1
  22. package/lib/cjs/solidity/SlotsParser.js +3 -1
  23. package/lib/cjs/solidity/SlotsParser.js.map +1 -1
  24. package/lib/cjs/tokens/TokenProviders/TPCoingecko.js +3 -1
  25. package/lib/cjs/tokens/TokenProviders/TPCoingecko.js.map +1 -1
  26. package/lib/cjs/txs/TxWriter.js +3 -1
  27. package/lib/cjs/txs/TxWriter.js.map +1 -1
  28. package/lib/cjs/txs/agents/BatchAgent.js +44 -4
  29. package/lib/cjs/txs/agents/BatchAgent.js.map +1 -1
  30. package/lib/cjs/utils/$bigfloat.js +24 -8
  31. package/lib/cjs/utils/$bigfloat.js.map +1 -1
  32. package/lib/esm/abi/coders/abstract-coder.js.map +1 -1
  33. package/lib/esm/abi/coders/abstract-coder.mjs +18 -7
  34. package/lib/esm/abi/fragments.js.map +1 -1
  35. package/lib/esm/abi/fragments.mjs +24 -8
  36. package/lib/esm/class/PackedRanges.js.map +1 -1
  37. package/lib/esm/class/PackedRanges.mjs +6 -2
  38. package/lib/esm/class/SubjectStream.js.map +1 -1
  39. package/lib/esm/class/SubjectStream.mjs +3 -1
  40. package/lib/esm/clients/WalletClient.js.map +1 -1
  41. package/lib/esm/clients/WalletClient.mjs +3 -1
  42. package/lib/esm/contracts/deploy/Deployments.js.map +1 -1
  43. package/lib/esm/contracts/deploy/Deployments.mjs +1 -1
  44. package/lib/esm/contracts/deploy/proxy/ProxyDeployment.js.map +1 -1
  45. package/lib/esm/contracts/deploy/proxy/ProxyDeployment.mjs +3 -1
  46. package/lib/esm/indexer/EventsIndexer.js.map +1 -1
  47. package/lib/esm/indexer/EventsIndexer.mjs +3 -1
  48. package/lib/esm/safe/GnosisSafeHandler.js.map +1 -1
  49. package/lib/esm/safe/GnosisSafeHandler.mjs +6 -1
  50. package/lib/esm/safe/transport/InMemoryServiceTransport.js.map +1 -1
  51. package/lib/esm/safe/transport/InMemoryServiceTransport.mjs +4 -4
  52. package/lib/esm/safe/transport/SafeServiceTransport.js.map +1 -1
  53. package/lib/esm/solidity/SlotsParser.js.map +1 -1
  54. package/lib/esm/solidity/SlotsParser.mjs +3 -1
  55. package/lib/esm/tokens/TokenProviders/TPCoingecko.js.map +1 -1
  56. package/lib/esm/tokens/TokenProviders/TPCoingecko.mjs +3 -1
  57. package/lib/esm/txs/TxWriter.js.map +1 -1
  58. package/lib/esm/txs/TxWriter.mjs +3 -1
  59. package/lib/esm/txs/agents/BatchAgent.js.map +1 -1
  60. package/lib/esm/txs/agents/BatchAgent.mjs +44 -4
  61. package/lib/esm/utils/$bigfloat.js.map +1 -1
  62. package/lib/esm/utils/$bigfloat.mjs +24 -8
  63. package/lib/types/abi/coders/abstract-coder.d.ts +18 -0
  64. package/lib/types/class/PackedRanges.d.ts +6 -0
  65. package/lib/types/class/SubjectStream.d.ts +3 -0
  66. package/lib/types/clients/WalletClient.d.ts +3 -0
  67. package/lib/types/contracts/deploy/proxy/ProxyDeployment.d.ts +3 -0
  68. package/lib/types/indexer/EventsIndexer.d.ts +3 -0
  69. package/lib/types/safe/transport/InMemoryServiceTransport.d.ts +1 -1
  70. package/lib/types/safe/transport/SafeServiceTransport.d.ts +2 -2
  71. package/lib/types/tokens/TokenProviders/TPCoingecko.d.ts +3 -0
  72. package/lib/types/txs/TxWriter.d.ts +3 -0
  73. package/lib/types/txs/agents/BatchAgent.d.ts +14 -0
  74. package/lib/types/utils/$bigfloat.d.ts +24 -0
  75. package/package.json +1 -1
  76. package/src/abi/coders/abstract-coder.ts +18 -7
  77. package/src/abi/fragments.ts +24 -8
  78. package/src/class/PackedRanges.ts +6 -2
  79. package/src/class/SubjectStream.ts +3 -1
  80. package/src/clients/WalletClient.ts +3 -1
  81. package/src/contracts/deploy/Deployments.ts +1 -1
  82. package/src/contracts/deploy/proxy/ProxyDeployment.ts +3 -1
  83. package/src/indexer/EventsIndexer.ts +3 -1
  84. package/src/safe/GnosisSafeHandler.ts +12 -10
  85. package/src/safe/transport/ISafeServiceTransport.ts +0 -3
  86. package/src/safe/transport/InMemoryServiceTransport.ts +7 -7
  87. package/src/safe/transport/SafeServiceTransport.ts +2 -5
  88. package/src/solidity/SlotsParser.ts +3 -1
  89. package/src/tokens/TokenProviders/TPCoingecko.ts +3 -1
  90. package/src/txs/TxWriter.ts +3 -1
  91. package/src/txs/agents/BatchAgent.ts +57 -4
  92. package/src/utils/$bigfloat.ts +24 -8
  93. package/lib/cjs/utils/$signRaw.js +0 -45
  94. package/lib/cjs/utils/$signRaw.js.map +0 -1
  95. package/lib/cjs/utils/$signRawNative.js +0 -91
  96. package/lib/cjs/utils/$signRawNative.js.map +0 -1
  97. package/lib/esm/utils/$signRaw.js.map +0 -1
  98. package/lib/esm/utils/$signRaw.mjs +0 -44
  99. package/lib/esm/utils/$signRawNative.js.map +0 -1
  100. package/lib/esm/utils/$signRawNative.mjs +0 -90
  101. package/lib/types/utils/$signRaw.d.ts +0 -1
  102. package/lib/types/utils/$signRawNative.d.ts +0 -1
  103. package/src/utils/$signRaw.ts +0 -50
  104. package/src/utils/$signRawNative.ts +0 -105
@@ -1,7 +1,8 @@
1
1
  import di from 'a-di';
2
- import memd from 'memd';
3
2
  import alot from 'alot';
4
3
 
4
+ import type { TAbiItem } from '@dequanto/types/TAbi';
5
+
5
6
  import { EoAccount, SafeAccount } from "@dequanto/models/TAccount";
6
7
  import { EthWeb3Client } from '@dequanto/clients/EthWeb3Client';
7
8
  import { Web3Client } from '@dequanto/clients/Web3Client';
@@ -16,17 +17,15 @@ import { $address } from '@dequanto/utils/$address';
16
17
  import { $logger } from '@dequanto/utils/$logger';
17
18
  import { $bigint } from '@dequanto/utils/$bigint';
18
19
  import { $promise } from '@dequanto/utils/$promise';
19
- import { $gnosis } from './$gnosis';
20
20
 
21
21
  import { TxDataBuilder } from '@dequanto/txs/TxDataBuilder';
22
-
23
- import type { TAbiItem } from '@dequanto/types/TAbi';
24
22
  import { $sig } from '@dequanto/utils/$sig';
25
23
  import { TEth } from '@dequanto/models/TEth';
26
24
  import { $abiUtils } from '@dequanto/utils/$abiUtils';
27
25
  import { $require } from '@dequanto/utils/$require';
28
26
  import { ChainAccountService } from '@dequanto/ChainAccountService';
29
27
  import { config } from '@dequanto/config/Config';
28
+ import { InMemoryServiceTransport } from './transport/InMemoryServiceTransport';
30
29
 
31
30
  export class GnosisSafeHandler {
32
31
 
@@ -44,7 +43,13 @@ export class GnosisSafeHandler {
44
43
  this.safeAddress = config.safeAddress;
45
44
  this.owners = config.owners;
46
45
  this.client = config.client ?? di.resolve(EthWeb3Client);
47
- this.transport = config.transport ?? new SafeServiceTransport(this.client, this.owners);
46
+ this.transport = config.transport ?? (
47
+ config.owners.length > 1
48
+ // when multiple owners are provided assume the transport is InMemory
49
+ ? new InMemoryServiceTransport(this.client, this.owners[0])
50
+ // otherwise use the default Safe Transaction Service
51
+ : new SafeServiceTransport(this.client, this.owners)
52
+ )
48
53
 
49
54
  $require.Address(this.safeAddress, `Safe address ${this.safeAddress} is not valid`);
50
55
  $require.True(this.owners != null && this.owners.length > 0, `At least one owner is required`);
@@ -170,8 +175,7 @@ export class GnosisSafeHandler {
170
175
  let safeTxData: SafeServiceTypes.SafeTransactionData = {
171
176
  ...safeTxEstimation,
172
177
 
173
- safeTxGas: 0, // Number(estimated.safeTxGas),
174
-
178
+ safeTxGas: 0,
175
179
  baseGas: 0,
176
180
  gasToken: $address.ZERO,
177
181
  refundReceiver: $address.ZERO,
@@ -220,12 +224,10 @@ export class GnosisSafeHandler {
220
224
  }
221
225
  }).toArrayAsync();
222
226
 
223
-
224
227
  let signatures = new Map();
225
228
  sigArr.forEach(sig => {
226
229
  signatures.set(sig.address, sig.signature);
227
- })
228
-
230
+ });
229
231
 
230
232
  // https://docs.gnosis-safe.io/tutorials/tutorial_tx_service_initiate_sign
231
233
  let owner = this.owners[0];
@@ -1,13 +1,10 @@
1
1
  import { TAddress } from '@dequanto/models/TAddress'
2
2
  import { SafeServiceTypes } from '../types/SafeServiceTypes'
3
3
 
4
-
5
4
  export interface ISafeServiceTransport {
6
5
 
7
6
  getTx (safeTxHash: string): Promise<SafeServiceTypes.SafeMultisigTransactionResponse>
8
7
 
9
- //getTransaction (safeTxHash: string): Promise<SafeMultisigTransactionResponse>
10
-
11
8
  getTxConfirmations (safeTxHash: string): Promise<SafeServiceTypes.SafeMultisigConfirmationListResponse>
12
9
 
13
10
  confirmTx(safeTxHash: string, sig: { signature: string, owner: TAddress }): Promise<SafeServiceTypes.SignatureResponse>
@@ -1,12 +1,11 @@
1
- import alot from 'alot';
2
- import { GnosisSafe } from '@dequanto/prebuilt/safe/GnosisSafe';
3
- import { Web3Client } from '@dequanto/clients/Web3Client';
1
+ import type { Web3Client } from '@dequanto/clients/Web3Client';
4
2
  import type { EoAccount } from '@dequanto/models/TAccount';
5
3
  import type { TAddress } from '@dequanto/models/TAddress';
6
-
7
4
  import type { ISafeServiceTransport } from './ISafeServiceTransport';
8
5
  import { SafeServiceTypes } from '../types/SafeServiceTypes';
9
6
 
7
+ import { ContractReader } from '@dequanto/contracts/ContractReader';
8
+
10
9
  export class InMemoryServiceTransport implements ISafeServiceTransport {
11
10
 
12
11
  txs = {} as {
@@ -47,10 +46,11 @@ export class InMemoryServiceTransport implements ISafeServiceTransport {
47
46
  }
48
47
 
49
48
  async getSafeInfo(safeAddress: TAddress): Promise<{ nonce, threshold }> {
50
- let contract = new GnosisSafe(safeAddress, this.client);
49
+
50
+ let contract = new ContractReader(this.client);
51
51
  let [ nonce, threshold ] = await Promise.all([
52
- contract.nonce(),
53
- contract.getThreshold(),
52
+ contract.readAsync<bigint>(safeAddress, 'function nonce() view returns (uint256)'),
53
+ contract.readAsync<bigint>(safeAddress, 'function getThreshold() view returns (uint256)'),
54
54
  ]);
55
55
 
56
56
  return { nonce, threshold };
@@ -1,5 +1,5 @@
1
- import { Web3Client } from '@dequanto/clients/Web3Client';
2
- import { EoAccount } from '@dequanto/models/TAccount';
1
+ import type { Web3Client } from '@dequanto/clients/Web3Client';
2
+ import type { EoAccount } from '@dequanto/models/TAccount';
3
3
  import { TAddress } from '@dequanto/models/TAddress';
4
4
 
5
5
  import memd from 'memd';
@@ -9,7 +9,6 @@ import { TPlatform } from '@dequanto/models/TPlatform';
9
9
  import { config } from '@dequanto/config/Config';
10
10
  import { $require } from '@dequanto/utils/$require';
11
11
  import { SafeServiceTypes } from '../types/SafeServiceTypes';
12
- import { $bigint } from '@dequanto/utils/$bigint';
13
12
 
14
13
  // https://safe-transaction-mainnet.safe.global/?format=openapi
15
14
 
@@ -56,8 +55,6 @@ export class SafeServiceTransport implements ISafeServiceTransport {
56
55
  await service.proposeTransaction(args);
57
56
  }
58
57
 
59
-
60
-
61
58
  @memd.deco.memoize({ perInstance: true })
62
59
  private async getService(): Promise<SafeServiceClientInner> {
63
60
  const url = await this.getServiceApiEndpoint(this.client.platform);
@@ -256,7 +256,9 @@ namespace TypeUtil {
256
256
 
257
257
  }
258
258
 
259
- // Calculate the SLOTs size of the enum excluding any dynamic values that are stored in offset
259
+ /**
260
+ * Calculates the slot size of the enum, excluding dynamic values stored by offset.
261
+ */
260
262
  async sizeOf () {
261
263
  let definition = await this.getDefinition();
262
264
  if (definition.type === 'ContractDefinition') {
@@ -133,7 +133,9 @@ export class TPCoingecko extends ATokenProvider implements ITokenProvider {
133
133
  return info;
134
134
  }
135
135
 
136
- // 50 per minute
136
+ /**
137
+ * Limits Coingecko requests to 50 per minute.
138
+ */
137
139
  @memd.deco.throttle(60 * 1000 / 50)
138
140
  private async _downloadTokenInfo (id: string) {
139
141
 
@@ -589,7 +589,9 @@ export class TxWriter extends class_EventEmitter<ITxWriterEvents> implements ITx
589
589
  };
590
590
  }
591
591
 
592
- //** We can save the Tx Data for later reuse/blockchain send */
592
+ /**
593
+ * Saves the transaction data for later reuse or blockchain submission.
594
+ */
593
595
  async saveTxAndExit (additionalProperties?) {
594
596
  let path = this.options?.txOutput;
595
597
  $require.notNull(path, 'Save tx data to the file, but the path is undefined');
@@ -1,4 +1,5 @@
1
1
  import alot from 'alot';
2
+ import type { Deployments } from '@dequanto/contracts/deploy/Deployments';
2
3
  import { EoAccount } from '@dequanto/models/TAccount';
3
4
  import { ITxWriterAgent } from './TxWriterAccountAgents';
4
5
  import { ITxWriterEmitter, ITxWriterEvents, ITxWriterTransaction, TxWriter } from '../TxWriter';
@@ -16,6 +17,8 @@ import { TimelockService } from '@dequanto/services/TimelockService/TimelockServ
16
17
  import { TxDataBuilder } from '../TxDataBuilder';
17
18
  import { $contract } from '@dequanto/utils/$contract';
18
19
  import { $require } from '@dequanto/utils/$require';
20
+ import { $account } from '@dequanto/utils/$account';
21
+
19
22
 
20
23
  export class BatchAgent implements ITxWriterAgent {
21
24
 
@@ -53,7 +56,9 @@ export class BatchAgent implements ITxWriterAgent {
53
56
  });
54
57
  }
55
58
 
56
- // Called by TxWriter for regular transactions. Prevents on-chain submission and keeps the transaction in the batch.
59
+ /**
60
+ * Called by TxWriter for regular transactions. Prevents on-chain submission and keeps the transaction in the batch.
61
+ */
57
62
  async process (senderMix: string | EoAccount, account: TEth.IAccount, outerWriter: TxWriter) {
58
63
 
59
64
  if (outerWriter.builder.data.to == null && this.options?.ignoreContractCreation != false) {
@@ -78,7 +83,10 @@ export class BatchAgent implements ITxWriterAgent {
78
83
  return inner;
79
84
  }
80
85
 
81
- // Submits queued transactions on-chain. If the account is Safe or Timelock, prepares the corresponding calldata and submits as batch transaction.
86
+ /**
87
+ * Submits queued transactions on-chain. If the account is Safe or Timelock,
88
+ * prepares the corresponding calldata and submits it as a batch transaction.
89
+ */
82
90
  async execute (): Promise<TxWriter[]> {
83
91
  this.disable();
84
92
 
@@ -103,14 +111,59 @@ export class BatchAgent implements ITxWriterAgent {
103
111
  return writers;
104
112
  }
105
113
 
114
+ /**
115
+ * Format all queued transactions for display.
116
+ */
117
+ async print (data?: {
118
+ deployments: Deployments[]
119
+ }): Promise<string> {
120
+ const contracts = await alot(data?.deployments ?? [])
121
+ .mapManyAsync(d => d.store.getDeployments())
122
+ .toArrayAsync();
123
+
124
+ const lines = await alot(this.transactions).mapManyAsync(async (tx, i) => {
125
+ let builder = tx.outerWriter.builder;
126
+ let data = builder.data;
127
+ let info = await builder.getInputDataInfo();
128
+ let arr = [];
129
+
130
+ let localContract = contracts.find(x => $address.eq(x.address, data.to));
131
+ let acc = tx.account ?? tx.sender;
132
+
133
+ arr.push(
134
+ `Transaction: #${i + 1}`,
135
+ ` To: ${data.to} ${localContract?.id ?? ''}`,
136
+ ` From: ${acc.address} ${acc.name}`,
137
+ ` Data: ${data.data}`,
138
+ );
139
+ if (info?.method) {
140
+ arr.push(` Function : ${info.method}`);
141
+ if (info.params != null) {
142
+ arr.push(` Parameters:`);
143
+ if (Array.isArray(info.params)) {
144
+ info.params.forEach(val => arr.push(` ${JSON.stringify(val)}`));
145
+ } else if (typeof info.params === 'object') {
146
+ alot
147
+ .fromObject(info.params)
148
+ .forEach(entry => arr.push(` ${entry.key}: ${JSON.stringify(entry.value)}`))
149
+ .toArray();
150
+ }
151
+ }
152
+ }
153
+ return arr;
154
+ }).toArrayAsync();
155
+
156
+ return lines.join('\n');
157
+ }
158
+
106
159
  private async executeGroup (txs: MockTxWriter[]) {
107
160
  let { account, sender } = txs[0];
108
161
  let acc = account ?? sender;
109
- if (acc.name.includes('safe/')) {
162
+ if ($account.isSafe(acc)) {
110
163
  let tx = await this.executeBatchSafe(acc, txs);
111
164
  return [ tx ];
112
165
  }
113
- if (acc.name.includes('timelock/')) {
166
+ if ($account.isTimelock(acc)) {
114
167
  let tx = await this.executeBatchTimelock(sender, account, txs);
115
168
  return [ tx ];
116
169
  }
@@ -84,7 +84,9 @@ export class BigFloat {
84
84
  return new Intl.NumberFormat(locales, options).format(str as any);
85
85
  }
86
86
 
87
- // a-b
87
+ /**
88
+ * a - b
89
+ */
88
90
  minus (mix: TNumeric) {
89
91
  return math.minus(this, from(mix));
90
92
  }
@@ -92,7 +94,9 @@ export class BigFloat {
92
94
  return math.minus(this, from(mix));
93
95
  }
94
96
 
95
- // a+b
97
+ /**
98
+ * a + b
99
+ */
96
100
  plus (mix: TNumeric) {
97
101
  return math.plus(this, from(mix));
98
102
  }
@@ -100,24 +104,34 @@ export class BigFloat {
100
104
  return math.plus(this, from(mix));
101
105
  }
102
106
 
103
- // a*b
107
+ /**
108
+ * a * b
109
+ */
104
110
  multipliedBy (mix: TNumeric) {
105
111
  return math.mul(this, from(mix));
106
112
  }
107
- // a*b
113
+ /**
114
+ * a * b
115
+ */
108
116
  times (mix: TNumeric) {
109
117
  return math.mul(this, from(mix));
110
118
  }
111
- // a*b
119
+ /**
120
+ * a * b
121
+ */
112
122
  mul (mix: TNumeric) {
113
123
  return math.mul(this, from(mix));
114
124
  }
115
125
 
116
- // a/b
126
+ /**
127
+ * a / b
128
+ */
117
129
  dividedBy (mix: TNumeric) {
118
130
  return math.div(this, from(mix));
119
131
  }
120
- // a/b
132
+ /**
133
+ * a / b
134
+ */
121
135
  div (mix: TNumeric) {
122
136
  return math.div(this, from(mix));
123
137
  }
@@ -155,7 +169,9 @@ export class BigFloat {
155
169
  return math.mod(this, from(mix));
156
170
  }
157
171
 
158
- //Supports negative and fractional numbers
172
+ /**
173
+ * Supports negative and fractional exponents.
174
+ */
159
175
  pow (exponent: number | bigint) {
160
176
  return math.pow(this, exponent)
161
177
  }
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- throw new Error(`Deprecated. Use @dequanto/utils/$sig instead.`);
4
- // export namespace $signRaw {
5
- // export function signEC (message: string | Buffer, privateKey: string | Buffer) {
6
- // const sig = ecsign(
7
- // toBuffer(message) as Buffer,
8
- // toBuffer(privateKey, { encoding: 'hex' }) as Buffer
9
- // );
10
- // let r = sig.r.toString('hex').padStart(64, '0')
11
- // let s = sig.s.toString('hex').padStart(64, '0');
12
- // let v = sig.v.toString(16);
13
- // return {
14
- // v: `0x${v}`,
15
- // r: `0x${r}`,
16
- // s: `0x${s}`,
17
- // signature: `0x${r}${s}${v}`,
18
- // signatureVRS: `0x${v}${r}${s}`
19
- // }
20
- // }
21
- // export function signEIPHashed (message: string | Buffer, privateKey: string) {
22
- // const buffer = toBuffer(message);
23
- // const hash = hashPersonalMessage(buffer as Buffer);
24
- // return signEC(hash, privateKey);
25
- // }
26
- // export function ecrecover (message: string, signature: string | { v, r, s}): TAddress {
27
- // return utils.recoverAddress(message, signature) as TAddress;
28
- // }
29
- // function toBuffer (message: string | Buffer, opts?: { encoding?: 'utf8' | 'hex' }) {
30
- // if (typeof message === 'string') {
31
- // let encoding = opts?.encoding;
32
- // if (encoding == null && $is.Hex(message)) {
33
- // encoding = 'hex';
34
- // message = message.substring(2);
35
- // }
36
- // if (encoding === 'hex') {
37
- // return $buffer.fromHex(message);
38
- // }
39
- // return $buffer.fromString(message, opts?.encoding ?? 'utf8');
40
- // }
41
- // return message;
42
- // }
43
- // }
44
- //# sourceMappingURL=$signRaw.js.map
45
- //# sourceMappingURL=$signRaw.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"$signRaw.js","sourceRoot":"","sources":["../../../src/utils/$signRaw.ts"],"names":[],"mappings":";;AAIA,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;AAEjE,8BAA8B;AAC9B,uFAAuF;AACvF,8BAA8B;AAC9B,2CAA2C;AAC3C,kEAAkE;AAClE,aAAa;AAEb,0DAA0D;AAC1D,2DAA2D;AAC3D,sCAAsC;AAEtC,mBAAmB;AACnB,2BAA2B;AAC3B,2BAA2B;AAC3B,2BAA2B;AAC3B,2CAA2C;AAC3C,6CAA6C;AAC7C,YAAY;AACZ,QAAQ;AACR,qFAAqF;AACrF,4CAA4C;AAC5C,8DAA8D;AAC9D,2CAA2C;AAC3C,QAAQ;AAER,8FAA8F;AAC9F,uEAAuE;AACvE,QAAQ;AAER,2FAA2F;AAC3F,6CAA6C;AAC7C,6CAA6C;AAC7C,0DAA0D;AAC1D,oCAAoC;AACpC,kDAAkD;AAClD,gBAAgB;AAChB,wCAAwC;AACxC,mDAAmD;AACnD,gBAAgB;AAChB,4EAA4E;AAC5E,YAAY;AACZ,0BAA0B;AAC1B,QAAQ;AACR,IAAI"}
@@ -1,91 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- throw new Error(`Deprecated. Use @dequanto/utils/$sig instead.`);
4
- // export namespace $signRawNative {
5
- // export function signEC (message: string | Uint8Array, privateKey: string | Uint8Array, chainId?: number) {
6
- // const sig = secp256k1.sign(
7
- // toUint8Array(message) as Uint8Array,
8
- // toUint8Array(privateKey, { encoding: 'hex' }) as Uint8Array
9
- // );
10
- // let r = sig.r.toString(16).padStart(64, '0');
11
- // let s = sig.s.toString(16).padStart(64, '0');
12
- // // https://eips.ethereum.org/EIPS/eip-155
13
- // let v = (chainId != null
14
- // ? sig.recovery + chainId * 2 + 35
15
- // : sig.recovery + 27
16
- // ).toString(16);
17
- // return {
18
- // v: `0x${v}`,
19
- // r: `0x${r}`,
20
- // s: `0x${s}`,
21
- // signature: `0x${r}${s}${v}`,
22
- // signatureVRS: `0x${v}${r}${s}`
23
- // }
24
- // }
25
- // export function signEIPHashed (message: string | Uint8Array, privateKey: string) {
26
- // const buffer = toUint8Array(message);
27
- // const hash = hashPersonalMessage(buffer);
28
- // return signEC(hash, privateKey);
29
- // }
30
- // export function ecrecover (digest: TEth.Hex | Uint8Array, signature: TEth.Hex | { v, r, s }): TEth.Address {
31
- // return recoverAddress(digest, signature);
32
- // }
33
- // export function eipRecover (message: string | Uint8Array, signature: TEth.Hex | { v, r, s }): TEth.Address {
34
- // const buffer = toUint8Array(message);
35
- // const hash = hashPersonalMessage(buffer);
36
- // return recoverAddress(hash, signature);
37
- // }
38
- // export function recoverAddress (digest: TEth.Hex | Uint8Array, signature: TEth.Hex | { v, r, s }): Promise<TEth.Address> {
39
- // const publicKey = recoverPubKey(digest, signature);
40
- // const address = $contract.keccak256(`0x${publicKey.substring(4)}`).slice(-40)
41
- // return $address.toChecksum(`0x${address}`);
42
- // }
43
- // export function recoverPubKey (digest: TEth.Hex | Uint8Array, signature: TEth.Hex | { v, r, s }) {
44
- // let { v, r, s } = $is.Hex(signature)
45
- // ? splitSignature(signature)
46
- // : signature;
47
- // let vNum = Number(v);
48
- // let recovery: 0 | 1;
49
- // if (vNum === 0 || vNum === 1) {
50
- // recovery = vNum;
51
- // } else if (vNum === 27 || vNum === 28) {
52
- // recovery = (vNum - 27) as 0 | 1;
53
- // } else if (vNum > 35) {
54
- // vNum -= 35;
55
- // recovery = vNum % 2 === 0 ? 0 : 1;
56
- // }
57
- // r = r.substring(2);
58
- // s = s.substring(2);
59
- // const publicKey = secp256k1.Signature.fromCompact(`${r}${s}`)
60
- // .addRecoveryBit(recovery)
61
- // .recoverPublicKey($hex.raw($hex.ensure(digest)))
62
- // .toHex(false);
63
- // return `0x${publicKey}`
64
- // }
65
- // function splitSignature (signature: TEth.Hex): { v, r, s} {
66
- // let r = signature.substring(2, 2 + 64);
67
- // let s = signature.substring(2 + 64, 2 + 64 + 64);
68
- // let v = signature.substring(2 + 64 + 64);
69
- // return { r, s ,v };
70
- // }
71
- // function hashPersonalMessage (buffer: Uint8Array) {
72
- // const prefix = $buffer.fromString(`\u0019Ethereum Signed Message:\n${buffer.length}`, 'utf-8')
73
- // return $contract.keccak256($buffer.concat([prefix, buffer]))
74
- // }
75
- // function toUint8Array (message: string | Uint8Array, opts?: { encoding?: 'utf8' | 'hex' }): Uint8Array {
76
- // if (typeof message === 'string') {
77
- // let encoding = opts?.encoding;
78
- // if (encoding == null && $is.Hex(message)) {
79
- // encoding = 'hex';
80
- // message = message.substring(2);
81
- // }
82
- // if (encoding === 'hex') {
83
- // return $buffer.fromHex(message);
84
- // }
85
- // return $buffer.fromString(message, opts?.encoding ?? 'utf8');
86
- // }
87
- // return message;
88
- // }
89
- // }
90
- //# sourceMappingURL=$signRawNative.js.map
91
- //# sourceMappingURL=$signRawNative.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"$signRawNative.js","sourceRoot":"","sources":["../../../src/utils/$signRawNative.ts"],"names":[],"mappings":";;AAQA,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;AAEjE,oCAAoC;AACpC,iHAAiH;AACjH,sCAAsC;AACtC,mDAAmD;AACnD,0EAA0E;AAC1E,aAAa;AAEb,wDAAwD;AACxD,wDAAwD;AACxD,oDAAoD;AACpD,mCAAmC;AACnC,gDAAgD;AAChD,kCAAkC;AAClC,0BAA0B;AAE1B,mBAAmB;AACnB,2BAA2B;AAC3B,2BAA2B;AAC3B,2BAA2B;AAC3B,2CAA2C;AAC3C,6CAA6C;AAC7C,YAAY;AACZ,QAAQ;AACR,yFAAyF;AACzF,gDAAgD;AAChD,oDAAoD;AACpD,2CAA2C;AAC3C,QAAQ;AAER,mHAAmH;AACnH,oDAAoD;AACpD,QAAQ;AACR,mHAAmH;AACnH,gDAAgD;AAChD,oDAAoD;AACpD,kDAAkD;AAClD,QAAQ;AAER,iIAAiI;AACjI,8DAA8D;AAC9D,wFAAwF;AACxF,sDAAsD;AACtD,QAAQ;AACR,yGAAyG;AACzG,+CAA+C;AAC/C,0CAA0C;AAC1C,2BAA2B;AAE3B,gCAAgC;AAChC,+BAA+B;AAC/B,0CAA0C;AAC1C,+BAA+B;AAC/B,mDAAmD;AACnD,+CAA+C;AAC/C,kCAAkC;AAClC,0BAA0B;AAC1B,iDAAiD;AACjD,YAAY;AACZ,8BAA8B;AAC9B,8BAA8B;AAE9B,wEAAwE;AACxE,wCAAwC;AACxC,+DAA+D;AAC/D,6BAA6B;AAC7B,oCAAoC;AACpC,QAAQ;AAER,kEAAkE;AAClE,kDAAkD;AAClD,4DAA4D;AAC5D,oDAAoD;AACpD,8BAA8B;AAC9B,QAAQ;AAER,0DAA0D;AAC1D,yGAAyG;AACzG,uEAAuE;AACvE,QAAQ;AAER,+GAA+G;AAC/G,6CAA6C;AAC7C,6CAA6C;AAC7C,0DAA0D;AAC1D,oCAAoC;AACpC,kDAAkD;AAClD,gBAAgB;AAChB,wCAAwC;AACxC,mDAAmD;AACnD,gBAAgB;AAChB,4EAA4E;AAC5E,YAAY;AACZ,0BAA0B;AAC1B,QAAQ;AACR,IAAI"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"$signRaw.js","sourceRoot":"","sources":["../../../src/utils/$signRaw.ts"],"names":[],"mappings":";;AAIA,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;AAEjE,8BAA8B;AAC9B,uFAAuF;AACvF,8BAA8B;AAC9B,2CAA2C;AAC3C,kEAAkE;AAClE,aAAa;AAEb,0DAA0D;AAC1D,2DAA2D;AAC3D,sCAAsC;AAEtC,mBAAmB;AACnB,2BAA2B;AAC3B,2BAA2B;AAC3B,2BAA2B;AAC3B,2CAA2C;AAC3C,6CAA6C;AAC7C,YAAY;AACZ,QAAQ;AACR,qFAAqF;AACrF,4CAA4C;AAC5C,8DAA8D;AAC9D,2CAA2C;AAC3C,QAAQ;AAER,8FAA8F;AAC9F,uEAAuE;AACvE,QAAQ;AAER,2FAA2F;AAC3F,6CAA6C;AAC7C,6CAA6C;AAC7C,0DAA0D;AAC1D,oCAAoC;AACpC,kDAAkD;AAClD,gBAAgB;AAChB,wCAAwC;AACxC,mDAAmD;AACnD,gBAAgB;AAChB,4EAA4E;AAC5E,YAAY;AACZ,0BAA0B;AAC1B,QAAQ;AACR,IAAI"}
@@ -1,44 +0,0 @@
1
- throw new Error(`Deprecated. Use @dequanto/utils/$sig instead.`);
2
- export {};
3
- // export namespace $signRaw {
4
- // export function signEC (message: string | Buffer, privateKey: string | Buffer) {
5
- // const sig = ecsign(
6
- // toBuffer(message) as Buffer,
7
- // toBuffer(privateKey, { encoding: 'hex' }) as Buffer
8
- // );
9
- // let r = sig.r.toString('hex').padStart(64, '0')
10
- // let s = sig.s.toString('hex').padStart(64, '0');
11
- // let v = sig.v.toString(16);
12
- // return {
13
- // v: `0x${v}`,
14
- // r: `0x${r}`,
15
- // s: `0x${s}`,
16
- // signature: `0x${r}${s}${v}`,
17
- // signatureVRS: `0x${v}${r}${s}`
18
- // }
19
- // }
20
- // export function signEIPHashed (message: string | Buffer, privateKey: string) {
21
- // const buffer = toBuffer(message);
22
- // const hash = hashPersonalMessage(buffer as Buffer);
23
- // return signEC(hash, privateKey);
24
- // }
25
- // export function ecrecover (message: string, signature: string | { v, r, s}): TAddress {
26
- // return utils.recoverAddress(message, signature) as TAddress;
27
- // }
28
- // function toBuffer (message: string | Buffer, opts?: { encoding?: 'utf8' | 'hex' }) {
29
- // if (typeof message === 'string') {
30
- // let encoding = opts?.encoding;
31
- // if (encoding == null && $is.Hex(message)) {
32
- // encoding = 'hex';
33
- // message = message.substring(2);
34
- // }
35
- // if (encoding === 'hex') {
36
- // return $buffer.fromHex(message);
37
- // }
38
- // return $buffer.fromString(message, opts?.encoding ?? 'utf8');
39
- // }
40
- // return message;
41
- // }
42
- // }
43
- //# sourceMappingURL=$signRaw.js.map
44
- //# sourceMappingURL=$signRaw.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"$signRawNative.js","sourceRoot":"","sources":["../../../src/utils/$signRawNative.ts"],"names":[],"mappings":";;AAQA,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;AAEjE,oCAAoC;AACpC,iHAAiH;AACjH,sCAAsC;AACtC,mDAAmD;AACnD,0EAA0E;AAC1E,aAAa;AAEb,wDAAwD;AACxD,wDAAwD;AACxD,oDAAoD;AACpD,mCAAmC;AACnC,gDAAgD;AAChD,kCAAkC;AAClC,0BAA0B;AAE1B,mBAAmB;AACnB,2BAA2B;AAC3B,2BAA2B;AAC3B,2BAA2B;AAC3B,2CAA2C;AAC3C,6CAA6C;AAC7C,YAAY;AACZ,QAAQ;AACR,yFAAyF;AACzF,gDAAgD;AAChD,oDAAoD;AACpD,2CAA2C;AAC3C,QAAQ;AAER,mHAAmH;AACnH,oDAAoD;AACpD,QAAQ;AACR,mHAAmH;AACnH,gDAAgD;AAChD,oDAAoD;AACpD,kDAAkD;AAClD,QAAQ;AAER,iIAAiI;AACjI,8DAA8D;AAC9D,wFAAwF;AACxF,sDAAsD;AACtD,QAAQ;AACR,yGAAyG;AACzG,+CAA+C;AAC/C,0CAA0C;AAC1C,2BAA2B;AAE3B,gCAAgC;AAChC,+BAA+B;AAC/B,0CAA0C;AAC1C,+BAA+B;AAC/B,mDAAmD;AACnD,+CAA+C;AAC/C,kCAAkC;AAClC,0BAA0B;AAC1B,iDAAiD;AACjD,YAAY;AACZ,8BAA8B;AAC9B,8BAA8B;AAE9B,wEAAwE;AACxE,wCAAwC;AACxC,+DAA+D;AAC/D,6BAA6B;AAC7B,oCAAoC;AACpC,QAAQ;AAER,kEAAkE;AAClE,kDAAkD;AAClD,4DAA4D;AAC5D,oDAAoD;AACpD,8BAA8B;AAC9B,QAAQ;AAER,0DAA0D;AAC1D,yGAAyG;AACzG,uEAAuE;AACvE,QAAQ;AAER,+GAA+G;AAC/G,6CAA6C;AAC7C,6CAA6C;AAC7C,0DAA0D;AAC1D,oCAAoC;AACpC,kDAAkD;AAClD,gBAAgB;AAChB,wCAAwC;AACxC,mDAAmD;AACnD,gBAAgB;AAChB,4EAA4E;AAC5E,YAAY;AACZ,0BAA0B;AAC1B,QAAQ;AACR,IAAI"}
@@ -1,90 +0,0 @@
1
- throw new Error(`Deprecated. Use @dequanto/utils/$sig instead.`);
2
- export {};
3
- // export namespace $signRawNative {
4
- // export function signEC (message: string | Uint8Array, privateKey: string | Uint8Array, chainId?: number) {
5
- // const sig = secp256k1.sign(
6
- // toUint8Array(message) as Uint8Array,
7
- // toUint8Array(privateKey, { encoding: 'hex' }) as Uint8Array
8
- // );
9
- // let r = sig.r.toString(16).padStart(64, '0');
10
- // let s = sig.s.toString(16).padStart(64, '0');
11
- // // https://eips.ethereum.org/EIPS/eip-155
12
- // let v = (chainId != null
13
- // ? sig.recovery + chainId * 2 + 35
14
- // : sig.recovery + 27
15
- // ).toString(16);
16
- // return {
17
- // v: `0x${v}`,
18
- // r: `0x${r}`,
19
- // s: `0x${s}`,
20
- // signature: `0x${r}${s}${v}`,
21
- // signatureVRS: `0x${v}${r}${s}`
22
- // }
23
- // }
24
- // export function signEIPHashed (message: string | Uint8Array, privateKey: string) {
25
- // const buffer = toUint8Array(message);
26
- // const hash = hashPersonalMessage(buffer);
27
- // return signEC(hash, privateKey);
28
- // }
29
- // export function ecrecover (digest: TEth.Hex | Uint8Array, signature: TEth.Hex | { v, r, s }): TEth.Address {
30
- // return recoverAddress(digest, signature);
31
- // }
32
- // export function eipRecover (message: string | Uint8Array, signature: TEth.Hex | { v, r, s }): TEth.Address {
33
- // const buffer = toUint8Array(message);
34
- // const hash = hashPersonalMessage(buffer);
35
- // return recoverAddress(hash, signature);
36
- // }
37
- // export function recoverAddress (digest: TEth.Hex | Uint8Array, signature: TEth.Hex | { v, r, s }): Promise<TEth.Address> {
38
- // const publicKey = recoverPubKey(digest, signature);
39
- // const address = $contract.keccak256(`0x${publicKey.substring(4)}`).slice(-40)
40
- // return $address.toChecksum(`0x${address}`);
41
- // }
42
- // export function recoverPubKey (digest: TEth.Hex | Uint8Array, signature: TEth.Hex | { v, r, s }) {
43
- // let { v, r, s } = $is.Hex(signature)
44
- // ? splitSignature(signature)
45
- // : signature;
46
- // let vNum = Number(v);
47
- // let recovery: 0 | 1;
48
- // if (vNum === 0 || vNum === 1) {
49
- // recovery = vNum;
50
- // } else if (vNum === 27 || vNum === 28) {
51
- // recovery = (vNum - 27) as 0 | 1;
52
- // } else if (vNum > 35) {
53
- // vNum -= 35;
54
- // recovery = vNum % 2 === 0 ? 0 : 1;
55
- // }
56
- // r = r.substring(2);
57
- // s = s.substring(2);
58
- // const publicKey = secp256k1.Signature.fromCompact(`${r}${s}`)
59
- // .addRecoveryBit(recovery)
60
- // .recoverPublicKey($hex.raw($hex.ensure(digest)))
61
- // .toHex(false);
62
- // return `0x${publicKey}`
63
- // }
64
- // function splitSignature (signature: TEth.Hex): { v, r, s} {
65
- // let r = signature.substring(2, 2 + 64);
66
- // let s = signature.substring(2 + 64, 2 + 64 + 64);
67
- // let v = signature.substring(2 + 64 + 64);
68
- // return { r, s ,v };
69
- // }
70
- // function hashPersonalMessage (buffer: Uint8Array) {
71
- // const prefix = $buffer.fromString(`\u0019Ethereum Signed Message:\n${buffer.length}`, 'utf-8')
72
- // return $contract.keccak256($buffer.concat([prefix, buffer]))
73
- // }
74
- // function toUint8Array (message: string | Uint8Array, opts?: { encoding?: 'utf8' | 'hex' }): Uint8Array {
75
- // if (typeof message === 'string') {
76
- // let encoding = opts?.encoding;
77
- // if (encoding == null && $is.Hex(message)) {
78
- // encoding = 'hex';
79
- // message = message.substring(2);
80
- // }
81
- // if (encoding === 'hex') {
82
- // return $buffer.fromHex(message);
83
- // }
84
- // return $buffer.fromString(message, opts?.encoding ?? 'utf8');
85
- // }
86
- // return message;
87
- // }
88
- // }
89
- //# sourceMappingURL=$signRawNative.js.map
90
- //# sourceMappingURL=$signRawNative.ts.map
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};