dequanto 0.2.53 → 0.2.56
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/lib/cjs/abi/$abi.js +39 -1
- package/lib/cjs/abi/$abi.js.map +1 -1
- package/lib/cjs/contracts/ContractReader.js +2 -2
- package/lib/cjs/contracts/ContractReader.js.map +1 -1
- package/lib/cjs/gen/Generator.js +1 -0
- package/lib/cjs/gen/Generator.js.map +1 -1
- package/lib/cjs/gen/GeneratorFromAbi.js +38 -9
- package/lib/cjs/gen/GeneratorFromAbi.js.map +1 -1
- package/lib/cjs/safe/GnosisSafeHandler.js.map +1 -1
- package/lib/cjs/services/TimelockService/ITimelockService.js.map +1 -1
- package/lib/cjs/services/TimelockService/TimelockService.js +1 -1
- package/lib/cjs/services/TimelockService/TimelockService.js.map +1 -1
- package/lib/cjs/solidity/utils/$types.js +26 -0
- package/lib/cjs/solidity/utils/$types.js.map +1 -1
- package/lib/cjs/txs/TxWriter.js +6 -4
- package/lib/cjs/txs/TxWriter.js.map +1 -1
- package/lib/cjs/txs/agents/BatchAgent.js +32 -7
- package/lib/cjs/txs/agents/BatchAgent.js.map +1 -1
- package/lib/cjs/txs/agents/TxWriterAccountAgents.js +2 -0
- package/lib/cjs/txs/agents/TxWriterAccountAgents.js.map +1 -1
- package/lib/cjs/txs/agents/ZodiacAgent.js +20 -0
- package/lib/cjs/txs/agents/ZodiacAgent.js.map +1 -0
- package/lib/cjs/utils/$account.js +5 -1
- package/lib/cjs/utils/$account.js.map +1 -1
- package/lib/cjs/zodiac/ZodiacTx.js +83 -0
- package/lib/cjs/zodiac/ZodiacTx.js.map +1 -0
- package/lib/esm/abi/$abi.js.map +1 -1
- package/lib/esm/abi/$abi.mjs +36 -1
- package/lib/esm/contracts/ContractReader.js.map +1 -1
- package/lib/esm/contracts/ContractReader.mjs +2 -2
- package/lib/esm/gen/Generator.js.map +1 -1
- package/lib/esm/gen/Generator.mjs +1 -0
- package/lib/esm/gen/GeneratorFromAbi.js.map +1 -1
- package/lib/esm/gen/GeneratorFromAbi.mjs +38 -9
- package/lib/esm/safe/GnosisSafeHandler.js.map +1 -1
- package/lib/esm/services/TimelockService/ITimelockService.js.map +1 -1
- package/lib/esm/services/TimelockService/TimelockService.js.map +1 -1
- package/lib/esm/services/TimelockService/TimelockService.mjs +1 -1
- package/lib/esm/solidity/utils/$types.js.map +1 -1
- package/lib/esm/solidity/utils/$types.mjs +26 -0
- package/lib/esm/txs/TxWriter.js.map +1 -1
- package/lib/esm/txs/TxWriter.mjs +6 -4
- package/lib/esm/txs/agents/BatchAgent.js.map +1 -1
- package/lib/esm/txs/agents/BatchAgent.mjs +32 -7
- package/lib/esm/txs/agents/TxWriterAccountAgents.js.map +1 -1
- package/lib/esm/txs/agents/TxWriterAccountAgents.mjs +2 -0
- package/lib/esm/txs/agents/ZodiacAgent.js.map +1 -0
- package/lib/esm/txs/agents/ZodiacAgent.mjs +16 -0
- package/lib/esm/utils/$account.js.map +1 -1
- package/lib/esm/utils/$account.mjs +5 -1
- package/lib/esm/zodiac/ZodiacTx.js.map +1 -0
- package/lib/esm/zodiac/ZodiacTx.mjs +79 -0
- package/lib/types/contracts/ContractReader.d.ts +1 -1
- package/lib/types/gen/Generator.d.ts +17 -0
- package/lib/types/gen/GeneratorFromAbi.d.ts +7 -0
- package/lib/types/models/TAccount.d.ts +11 -2
- package/lib/types/models/TEth.d.ts +4 -1
- package/lib/types/services/TimelockService/ITimelockService.d.ts +1 -0
- package/lib/types/solidity/utils/$types.d.ts +8 -0
- package/lib/types/txs/agents/BatchAgent.d.ts +2 -1
- package/lib/types/txs/agents/ZodiacAgent.d.ts +7 -0
- package/lib/types/utils/$account.d.ts +2 -1
- package/lib/types/zodiac/ZodiacTx.d.ts +30 -0
- package/package.json +1 -1
- package/skills/dequanto/INDEX.md +1 -1
- package/skills/dequanto/SKILL.md +4 -3
- package/skills/dequanto/examples/browser-wallet.spec.ts +2 -1
- package/skills/dequanto/examples/config.spec.ts +2 -1
- package/skills/dequanto/examples/contract-read.spec.ts +2 -1
- package/skills/dequanto/examples/contract-write.spec.ts +2 -1
- package/skills/dequanto/examples/deploy-contract.spec.ts +2 -1
- package/skills/dequanto/examples/erc4337-userop.spec.ts +2 -1
- package/skills/dequanto/examples/explorer-abi.spec.ts +2 -1
- package/skills/dequanto/examples/generate-contract-class.spec.ts +2 -1
- package/skills/dequanto/examples/hardhat-debug.spec.ts +2 -1
- package/skills/dequanto/examples/hardhat-fork.spec.ts +2 -1
- package/skills/dequanto/examples/index-events.spec.ts +2 -1
- package/skills/dequanto/examples/live-events.spec.ts +2 -1
- package/skills/dequanto/examples/revert-error.spec.ts +2 -1
- package/skills/dequanto/examples/rpc-read.spec.ts +19 -5
- package/skills/dequanto/examples/safe-batch.spec.ts +92 -3
- package/skills/dequanto/examples/send-transaction.spec.ts +2 -1
- package/skills/dequanto/examples/storage.spec.ts +2 -1
- package/skills/dequanto/examples/token-transfer.spec.ts +2 -1
- package/skills/dequanto/examples/utils.spec.ts +2 -1
- package/skills/dequanto/references/safe-erc4337.md +50 -3
- package/skills/dequanto/references/tokens-accounts.md +1 -0
- package/skills/dequanto/references/transactions.md +2 -1
- package/src/abi/$abi.ts +36 -0
- package/src/contracts/ContractReader.ts +2 -2
- package/src/gen/Generator.ts +4 -0
- package/src/gen/GeneratorFromAbi.ts +40 -10
- package/src/models/TAccount.ts +17 -2
- package/src/models/TEth.ts +4 -1
- package/src/safe/GnosisSafeHandler.ts +12 -12
- package/src/services/TimelockService/ITimelockService.ts +2 -0
- package/src/services/TimelockService/TimelockService.ts +1 -1
- package/src/solidity/utils/$types.ts +27 -0
- package/src/txs/TxWriter.ts +6 -4
- package/src/txs/agents/BatchAgent.ts +33 -7
- package/src/txs/agents/TxWriterAccountAgents.ts +2 -0
- package/src/txs/agents/ZodiacAgent.ts +19 -0
- package/src/utils/$account.ts +6 -2
- package/src/zodiac/ZodiacTx.ts +99 -0
- package/typings/index.d.ts +1 -4
- package/typings/globals/atma-utest/index.d.ts +0 -53
- package/typings/globals/atma-utest/typings.json +0 -10
- package/typings/globals/axios/index.d.ts +0 -6
- package/typings/globals/mask/index.d.ts +0 -6
- package/typings/globals/mask/typings.json +0 -9
|
@@ -6,6 +6,7 @@ import { $date } from '../../utils/$date.mjs';
|
|
|
6
6
|
import { $address } from '../../utils/$address.mjs';
|
|
7
7
|
import { $logger } from '../../utils/$logger.mjs';
|
|
8
8
|
import { SafeTx } from '../../safe/SafeTx.mjs';
|
|
9
|
+
import { ZodiacTx } from '../../zodiac/ZodiacTx.mjs';
|
|
9
10
|
import { TimelockController } from '../../prebuilt/openzeppelin/TimelockController.mjs';
|
|
10
11
|
import { TimelockService } from '../../services/TimelockService/TimelockService.mjs';
|
|
11
12
|
import { $contract } from '../../utils/$contract.mjs';
|
|
@@ -57,7 +58,7 @@ export class BatchAgent {
|
|
|
57
58
|
/**
|
|
58
59
|
* Executes the queued transactions.
|
|
59
60
|
*
|
|
60
|
-
* By default, duplicate transactions are skipped. If the account is Safe or Timelock,
|
|
61
|
+
* By default, duplicate transactions are skipped. If the account is Safe, Zodiac, or Timelock,
|
|
61
62
|
* prepares the corresponding calldata and submits it as a batch transaction.
|
|
62
63
|
*
|
|
63
64
|
* @param options.includeDuplicates Include duplicate transactions in the execution batch.
|
|
@@ -68,10 +69,10 @@ export class BatchAgent {
|
|
|
68
69
|
if (options?.includeDuplicates !== true) {
|
|
69
70
|
txs = alot(txs).distinctBy(x => {
|
|
70
71
|
const data = x.outerWriter.builder.data;
|
|
71
|
-
|
|
72
|
-
// remove duplicates by [from,to,data]
|
|
72
|
+
// Remove duplicates by account, value, target, and calldata.
|
|
73
73
|
return [
|
|
74
|
-
|
|
74
|
+
this.getAccountKey(x),
|
|
75
|
+
String(data.value ?? 0),
|
|
75
76
|
data.to?.toLowerCase() ?? '',
|
|
76
77
|
data.data ?? ''
|
|
77
78
|
].join('');
|
|
@@ -84,9 +85,9 @@ export class BatchAgent {
|
|
|
84
85
|
let next = i < txs.length - 1
|
|
85
86
|
? txs[i + 1]
|
|
86
87
|
: null;
|
|
87
|
-
let acc0 =
|
|
88
|
-
let acc1 = next
|
|
89
|
-
if (next == null ||
|
|
88
|
+
let acc0 = this.getAccountKey(tx);
|
|
89
|
+
let acc1 = next == null ? null : this.getAccountKey(next);
|
|
90
|
+
if (next == null || acc0 !== acc1) {
|
|
90
91
|
let arr = await this.executeGroup(txs.slice(groupStart, i + 1));
|
|
91
92
|
writers.push(...arr);
|
|
92
93
|
groupStart = i + 1;
|
|
@@ -129,9 +130,33 @@ export class BatchAgent {
|
|
|
129
130
|
}).toArrayAsync();
|
|
130
131
|
return lines.join('\n');
|
|
131
132
|
}
|
|
133
|
+
getAccountKey(tx) {
|
|
134
|
+
let account = tx.account ?? tx.sender;
|
|
135
|
+
let address = (account.address ?? tx.sender?.address)?.toLowerCase();
|
|
136
|
+
if ($account.isZodiac(account)) {
|
|
137
|
+
let roleKey = account.roleKey?.toLowerCase() ?? '';
|
|
138
|
+
return `${address}-${roleKey}`;
|
|
139
|
+
}
|
|
140
|
+
return address;
|
|
141
|
+
}
|
|
132
142
|
async executeGroup(txs) {
|
|
133
143
|
let { account, sender } = txs[0];
|
|
134
144
|
let acc = account ?? sender;
|
|
145
|
+
if ($account.isZodiac(acc)) {
|
|
146
|
+
let first = txs[0].outerWriter;
|
|
147
|
+
let { client, builder, options } = first;
|
|
148
|
+
let zodiac = new ZodiacTx({
|
|
149
|
+
...acc,
|
|
150
|
+
operator: sender ?? acc.operator
|
|
151
|
+
}, client, {
|
|
152
|
+
builder: builder.config,
|
|
153
|
+
writer: options,
|
|
154
|
+
});
|
|
155
|
+
let calls = txs.map(x => x.outerWriter.builder.getTxData());
|
|
156
|
+
let writer = await zodiac.executeBatch(...calls);
|
|
157
|
+
await writer.wait();
|
|
158
|
+
return [writer];
|
|
159
|
+
}
|
|
135
160
|
if ($account.isSafe(acc)) {
|
|
136
161
|
let tx = await this.executeBatchSafe(acc, txs);
|
|
137
162
|
return [tx];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TxWriterAccountAgents.js","sourceRoot":"","sources":["../../../../src/txs/agents/TxWriterAccountAgents.ts"],"names":[],"mappings":";;;AAEA,2CAAwC;AACxC,iDAA8C;AAC9C,mDAAgD;
|
|
1
|
+
{"version":3,"file":"TxWriterAccountAgents.js","sourceRoot":"","sources":["../../../../src/txs/agents/TxWriterAccountAgents.ts"],"names":[],"mappings":";;;AAEA,2CAAwC;AACxC,iDAA8C;AAC9C,mDAAgD;AAChD,+CAA4C;AAW5C,IAAiB,qBAAqB,CAgBrC;AAhBD,WAAiB,qBAAqB;IAElC,MAAM,MAAM,GAA4B;QACpC,IAAI,qBAAS,EAAE;QACf,IAAI,yBAAW,EAAE;QACjB,IAAI,2BAAY,EAAE;QAClB,IAAI,6BAAa,EAAE;KACtB,CAAC;IAEF,SAAgB,QAAQ,CAAE,KAA4B;QAClD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAFe,8BAAQ,WAEvB,CAAA;IAED,SAAgB,GAAG,CAAE,OAAiB;QAClC,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IACzD,CAAC;IAFe,yBAAG,MAElB,CAAA;AACL,CAAC,EAhBgB,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAgBrC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { SafeAgent } from './SafeAgent.mjs';
|
|
2
2
|
import { Erc4337Agent } from './Erc4337Agent.mjs';
|
|
3
3
|
import { TimelockAgent } from './TimelockAgent.mjs';
|
|
4
|
+
import { ZodiacAgent } from './ZodiacAgent.mjs';
|
|
4
5
|
export var TxWriterAccountAgents;
|
|
5
6
|
(function (TxWriterAccountAgents) {
|
|
6
7
|
const agents = [
|
|
7
8
|
new SafeAgent(),
|
|
9
|
+
new ZodiacAgent(),
|
|
8
10
|
new Erc4337Agent(),
|
|
9
11
|
new TimelockAgent(),
|
|
10
12
|
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZodiacAgent.js","sourceRoot":"","sources":["../../../../src/txs/agents/ZodiacAgent.ts"],"names":[],"mappings":";;;AACA,sDAAmD;AACnD,uDAAoD;AAIpD,MAAa,WAAW;IACpB,QAAQ,CAAE,OAAiB;QACvB,OAAO,mBAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,OAAO,CAAE,MAAiB,EAAE,OAAsB,EAAE,WAAqB;QAC3E,IAAI,MAAM,GAAG,IAAI,mBAAQ,CAAC,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,MAAM,EAAE;YAC5E,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,MAAM;YACnC,MAAM,EAAE,WAAW,CAAC,OAAO;SAC9B,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAC3D,CAAC;CACJ;AAZD,kCAYC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { $account } from '../../utils/$account.mjs';
|
|
2
|
+
import { ZodiacTx } from '../../zodiac/ZodiacTx.mjs';
|
|
3
|
+
export class ZodiacAgent {
|
|
4
|
+
supports(account) {
|
|
5
|
+
return $account.isZodiac(account);
|
|
6
|
+
}
|
|
7
|
+
async process(sender, account, outerWriter) {
|
|
8
|
+
let zodiac = new ZodiacTx({ ...account, operator: sender }, outerWriter.client, {
|
|
9
|
+
builder: outerWriter.builder.config,
|
|
10
|
+
writer: outerWriter.options,
|
|
11
|
+
});
|
|
12
|
+
return zodiac.execute(outerWriter.builder.getTxData());
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ZodiacAgent.js.map
|
|
16
|
+
//# sourceMappingURL=ZodiacAgent.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"$account.js","sourceRoot":"","sources":["../../../src/utils/$account.ts"],"names":[],"mappings":";;;AACA,yCAAsC;AACtC,yCAAsC;AACtC,iCAA8B;AAE9B,IAAiB,QAAQ,
|
|
1
|
+
{"version":3,"file":"$account.js","sourceRoot":"","sources":["../../../src/utils/$account.ts"],"names":[],"mappings":";;;AACA,yCAAsC;AACtC,yCAAsC;AACtC,iCAA8B;AAE9B,IAAiB,QAAQ,CAsExB;AAtED,WAAiB,QAAQ;IAErB,SAAgB,SAAS,CAAE,OAAiB;QACxC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC7B,IAAI,mBAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;gBAC3B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;aAC/B;YACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;SAC5B;QAED,IAAI,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,SAAS,CAAE,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC;YACxF,CAAC,CAAC,OAAO,CAAC,QAAQ;YAClB,CAAC,CAAC,OAAO,CAAC;QAEd,mBAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,2BAA4B,OAAO,EAAE,OAAO,IAAI,OAAQ,EAAE,CAAC,CAAC;QAClF,OAAO,GAAgB,CAAC;IAC5B,CAAC;IAde,kBAAS,YAcxB,CAAA;IAED,SAAgB,QAAQ,CAAE,OAAiB;QACvC,OAAO,OAAO,IAAI,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC;IACvF,CAAC;IAFe,iBAAQ,WAEvB,CAAA;IAED,SAAgB,MAAM,CAAE,OAAgB;QACpC,IAAI,OAAO,IAAI,IAAI,EAAE;YACjB,O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AAI,KAAK,QAAQ,EAAE;YAC1D,OAAO,OAAO,CAAC,IAAI,KAAK,UAAU,CAAC;SACtC;QACD,2CAA2C;QAC3C,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAbe,mBAAU,aAazB,CAAA;IAED,SAAgB,QAAQ,CAAC,IAAY;QACjC,OAAO,WAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,CAAC;IAFe,iBAAQ,WAEvB,CAAA;AACL,CAAC,EAtEgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAsExB"}
|
|
@@ -10,13 +10,17 @@ export var $account;
|
|
|
10
10
|
}
|
|
11
11
|
return { name: account };
|
|
12
12
|
}
|
|
13
|
-
let acc = isSafe(account) || isErc4337(account) || isTimelock(account)
|
|
13
|
+
let acc = isSafe(account) || isErc4337(account) || isTimelock(account) || isZodiac(account)
|
|
14
14
|
? account.operator
|
|
15
15
|
: account;
|
|
16
16
|
$require.notNull(acc, `Sender not resolved for ${account?.address ?? account}`);
|
|
17
17
|
return acc;
|
|
18
18
|
}
|
|
19
19
|
$account.getSender = getSender;
|
|
20
|
+
function isZodiac(account) {
|
|
21
|
+
return account != null && typeof account === 'object' && account.type === 'zodiac';
|
|
22
|
+
}
|
|
23
|
+
$account.isZodiac = isZodiac;
|
|
20
24
|
function isSafe(account) {
|
|
21
25
|
if (account == null) {
|
|
22
26
|
return false;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZodiacTx.js","sourceRoot":"","sources":["../../../src/zodiac/ZodiacTx.ts"],"names":[],"mappings":";;;AAGA,mDAAgD;AAEhD,8DAA2D;AAC3D,oDAAmE;AACnE,4CAAyC;AACzC,wDAAqD;AACrD,8CAA2C;AAC3C,sDAAmD;AAInD,iFAAiF;AACjF,MAAa,QAAQ;IACjB,YACW,OAAsB,EACtB,MAAkB,EAClB,OAIN;QAN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AAQ,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,6BAA6B,CAAC,CAAC;QACvE,IAAI,MAAM,GAAG,MAAM,mBAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAClE,IAAI,OAAO,GAAG,IAAI,6BAAa,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAClF,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC;QACnC,MAAM,OAAO,CAAC,MAAM,CAAC;YACjB,KAAK,EAAE,MAAM,EAAE,QAAQ;YACvB,UAAU,EAAE,MAAM,EAAE,aAAa;YACjC,QAAQ,EAAE,MAAM,EAAE,QAAQ;YAC1B,aAAa,EAAE,MAAM,EAAE,aAAa;YACpC,aAAa,EAAE,MAAM,EAAE,aAAa;YACpC,IAAI,EAAE,MAAM,EAAE,IAAI,IAAI,MAAM,CAAC,OAAO;YACpC,IAAI,EAAE,MAAM,EAAE,IAAI;SACrB,CAAC,CAAC;QACH,OAAO,mBAAQ;aACV,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC;aACpC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;CACJ;AAnFD,4BAmFC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { config } from '../config/Config.mjs';
|
|
2
|
+
import { TxDataBuilder } from '../txs/TxDataBuilder.mjs';
|
|
3
|
+
import { TxWriter } from '../txs/TxWriter.mjs';
|
|
4
|
+
import { $abi } from '../abi/$abi.mjs';
|
|
5
|
+
import { $abiUtils } from '../utils/$abiUtils.mjs';
|
|
6
|
+
import { $hex } from '../utils/$hex.mjs';
|
|
7
|
+
import { $require } from '../utils/$require.mjs';
|
|
8
|
+
/** Roles v2 execution. Inner values are paid by the avatar, not the operator. */
|
|
9
|
+
export class ZodiacTx {
|
|
10
|
+
constructor(account, client, options) {
|
|
11
|
+
this.account = account;
|
|
12
|
+
this.client = client;
|
|
13
|
+
this.options = options;
|
|
14
|
+
}
|
|
15
|
+
/** Encode a transaction to the Roles Modifier without submitting it. */
|
|
16
|
+
getTxData(call, operation = 0) {
|
|
17
|
+
$require.Address(this.account.address, 'Zodiac Roles Modifier address');
|
|
18
|
+
$require.Hex(this.account.roleKey, 'Zodiac roleKey must be hex');
|
|
19
|
+
$require.Address(call.to, 'Zodiac transaction target');
|
|
20
|
+
return {
|
|
21
|
+
to: this.account.address,
|
|
22
|
+
value: 0n,
|
|
23
|
+
data: $abi.encodeCall('execTransactionWithRole(address to,uint256 value,bytes data,uint8 operation,bytes32 roleKey,bool shouldRevert)', [
|
|
24
|
+
call.to,
|
|
25
|
+
call.value ?? 0n,
|
|
26
|
+
call.data ?? '0x',
|
|
27
|
+
operation,
|
|
28
|
+
$hex.padBytes(this.account.roleKey ?? '0x0', 32),
|
|
29
|
+
true
|
|
30
|
+
])
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** The Roles Modifier must have an unwrapper registered for this MultiSend deployment. */
|
|
34
|
+
getBatchTxData(...calls) {
|
|
35
|
+
$require.gt(calls.length, 0, 'Zodiac batch must not be empty');
|
|
36
|
+
let getAddress = (key) => {
|
|
37
|
+
return this.options?.contracts?.[this.client.network]?.[key]
|
|
38
|
+
?? config.safe?.contracts?.[this.client.network]?.[key];
|
|
39
|
+
};
|
|
40
|
+
let multiSendAddress = getAddress('MultiSendCallOnly') ?? getAddress('MultiSend');
|
|
41
|
+
$require.Address(multiSendAddress, 'Zodiac MultiSend contract');
|
|
42
|
+
let transactions = calls.map(call => {
|
|
43
|
+
$require.Address(call.to, 'Zodiac batch transaction target');
|
|
44
|
+
let data = call.data ?? '0x';
|
|
45
|
+
return $abiUtils.encodePacked(['uint8', 0], ['address', call.to], ['uint256', call.value ?? 0n], ['uint256', $hex.getBytesLength(data)], ['bytes', data]);
|
|
46
|
+
});
|
|
47
|
+
return this.getTxData({
|
|
48
|
+
to: multiSendAddress,
|
|
49
|
+
value: 0n,
|
|
50
|
+
data: $abi.encodeCall('multiSend(bytes transactions)', [$hex.concat(transactions)])
|
|
51
|
+
}, 1);
|
|
52
|
+
}
|
|
53
|
+
async execute(call) {
|
|
54
|
+
return this.send(this.getTxData(call));
|
|
55
|
+
}
|
|
56
|
+
async executeBatch(...calls) {
|
|
57
|
+
return this.send(this.getBatchTxData(...calls));
|
|
58
|
+
}
|
|
59
|
+
async send(data) {
|
|
60
|
+
$require.notNull(this.account.operator, 'Zodiac operator is required');
|
|
61
|
+
let sender = await TxWriter.prepareAccount(this.account.operator);
|
|
62
|
+
let builder = new TxDataBuilder(this.client, sender, data, this.options?.builder);
|
|
63
|
+
let config = this.options?.builder;
|
|
64
|
+
await builder.setGas({
|
|
65
|
+
price: config?.gasPrice,
|
|
66
|
+
priceRatio: config?.gasPriceRatio,
|
|
67
|
+
gasLimit: config?.gasLimit,
|
|
68
|
+
gasLimitRatio: config?.gasLimitRatio,
|
|
69
|
+
gasEstimation: config?.gasEstimation,
|
|
70
|
+
from: config?.from ?? sender.address,
|
|
71
|
+
type: config?.type,
|
|
72
|
+
});
|
|
73
|
+
return TxWriter
|
|
74
|
+
.create(this.client, builder, sender)
|
|
75
|
+
.send(this.options?.writer);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=ZodiacTx.js.map
|
|
79
|
+
//# sourceMappingURL=ZodiacTx.ts.map
|
|
@@ -48,7 +48,7 @@ export declare class ContractReader implements IContractReader {
|
|
|
48
48
|
[key: string]: any;
|
|
49
49
|
} | any[];
|
|
50
50
|
}): Promise<RpcTypes.Filter>;
|
|
51
|
-
static read<TResult = any>(client: Web3Client, address: TAddress, methodAbi: string): Promise<TResult>;
|
|
51
|
+
static read<TResult = any>(client: Web3Client, address: TAddress, methodAbi: string, ...params: any[]): Promise<TResult>;
|
|
52
52
|
}
|
|
53
53
|
export declare namespace ContractReaderUtils {
|
|
54
54
|
class DeferredRequest<T = any> {
|
|
@@ -27,6 +27,8 @@ export interface IGenerateOptions {
|
|
|
27
27
|
* c) Method function to read the implementation address from
|
|
28
28
|
*/
|
|
29
29
|
implementation?: TEth.Hex | TEth.Address | string;
|
|
30
|
+
/** When false: no files will be saved. Use "files" in result */
|
|
31
|
+
save?: boolean;
|
|
30
32
|
/** ABI will be save alongside with TS classes */
|
|
31
33
|
saveAbi?: boolean;
|
|
32
34
|
/** Sources will not be saved if FALSE */
|
|
@@ -44,6 +46,11 @@ export declare class Generator {
|
|
|
44
46
|
address: `0x${string}`;
|
|
45
47
|
implementation: `0x${string}`;
|
|
46
48
|
contractName: string;
|
|
49
|
+
files: {
|
|
50
|
+
kind: string;
|
|
51
|
+
path: string;
|
|
52
|
+
content: string;
|
|
53
|
+
}[];
|
|
47
54
|
}>;
|
|
48
55
|
static generateFromJson(artifact: string): Promise<{
|
|
49
56
|
main: string;
|
|
@@ -52,6 +59,11 @@ export declare class Generator {
|
|
|
52
59
|
address: `0x${string}`;
|
|
53
60
|
implementation: `0x${string}`;
|
|
54
61
|
contractName: string;
|
|
62
|
+
files: {
|
|
63
|
+
kind: string;
|
|
64
|
+
path: string;
|
|
65
|
+
content: string;
|
|
66
|
+
}[];
|
|
55
67
|
}>;
|
|
56
68
|
/**
|
|
57
69
|
* @deprecated Was possible to generate the Contract Class based on the meta information header in TS file
|
|
@@ -64,6 +76,11 @@ export declare class Generator {
|
|
|
64
76
|
address: `0x${string}`;
|
|
65
77
|
implementation: `0x${string}`;
|
|
66
78
|
contractName: string;
|
|
79
|
+
files: {
|
|
80
|
+
kind: string;
|
|
81
|
+
path: string;
|
|
82
|
+
content: string;
|
|
83
|
+
}[];
|
|
67
84
|
}>;
|
|
68
85
|
private getAbi;
|
|
69
86
|
private getSources;
|
|
@@ -13,6 +13,8 @@ export declare class GeneratorFromAbi {
|
|
|
13
13
|
output: string;
|
|
14
14
|
outputFileExt?: string;
|
|
15
15
|
implementation: TAddress;
|
|
16
|
+
/** No FS writes, use files in response */
|
|
17
|
+
save?: boolean;
|
|
16
18
|
saveAbi?: boolean;
|
|
17
19
|
saveSources?: boolean;
|
|
18
20
|
sources?: {
|
|
@@ -31,6 +33,11 @@ export declare class GeneratorFromAbi {
|
|
|
31
33
|
address: `0x${string}`;
|
|
32
34
|
implementation: `0x${string}`;
|
|
33
35
|
contractName: string;
|
|
36
|
+
files: {
|
|
37
|
+
kind: string;
|
|
38
|
+
path: string;
|
|
39
|
+
content: string;
|
|
40
|
+
}[];
|
|
34
41
|
}>;
|
|
35
42
|
private getRelativePath;
|
|
36
43
|
}
|
|
@@ -3,7 +3,7 @@ import { TAddress } from './TAddress';
|
|
|
3
3
|
import { TEth } from './TEth';
|
|
4
4
|
import { TPlatform } from './TPlatform';
|
|
5
5
|
export interface IAccount {
|
|
6
|
-
type?: 'eoa' | 'safe' | 'erc4337' | 'timelock' | 'impersonated';
|
|
6
|
+
type?: 'eoa' | 'safe' | 'erc4337' | 'timelock' | 'impersonated' | 'zodiac';
|
|
7
7
|
name?: string;
|
|
8
8
|
platform?: TPlatform;
|
|
9
9
|
address?: TAddress;
|
|
@@ -47,5 +47,14 @@ export interface TimelockAccount extends IAccount {
|
|
|
47
47
|
platform: TPlatform;
|
|
48
48
|
operator: IAccount;
|
|
49
49
|
}
|
|
50
|
-
export
|
|
50
|
+
export interface ZodiacAccount extends IAccount {
|
|
51
|
+
type: 'zodiac';
|
|
52
|
+
platform: TPlatform;
|
|
53
|
+
/** Zodiac Roles Modifier address, not the Safe/avatar address. */
|
|
54
|
+
address: TAddress;
|
|
55
|
+
operator: EoAccount;
|
|
56
|
+
/** Roles v2 bytes32 role key. */
|
|
57
|
+
roleKey: TEth.Hex;
|
|
58
|
+
}
|
|
59
|
+
export type TAccount = string | IAccount | EoAccount | SafeAccount | Erc4337Account | ZodiacAccount;
|
|
51
60
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ZodiacAccount as TZodiacAccount } from './TAccount';
|
|
1
2
|
import type { RpcTypes } from 'dequanto/rpc/Rpc';
|
|
2
3
|
import { TPlatform } from './TPlatform';
|
|
3
4
|
export declare namespace TEth {
|
|
@@ -107,7 +108,7 @@ export declare namespace TEth {
|
|
|
107
108
|
}
|
|
108
109
|
type Platform = 'eth' | 'eth:goerli' | 'bsc' | 'polygon' | 'arbitrum' | 'xdai' | 'boba' | 'hardhat' | 'optimism' | 'avalanche' | string;
|
|
109
110
|
interface IAccount {
|
|
110
|
-
type?: 'eoa' | 'safe' | 'erc4337' | 'timelock' | 'impersonated';
|
|
111
|
+
type?: 'eoa' | 'safe' | 'erc4337' | 'timelock' | 'impersonated' | 'zodiac';
|
|
111
112
|
name?: string;
|
|
112
113
|
address?: Address;
|
|
113
114
|
platform?: Platform;
|
|
@@ -123,6 +124,8 @@ export declare namespace TEth {
|
|
|
123
124
|
eth_signTypedData_v4(address: TEth.Address, typedData: Partial<RpcTypes.TypedData>): Promise<TEth.Hex>;
|
|
124
125
|
personal_sign(challenge: string, address: TEth.Address): Promise<TEth.Hex>;
|
|
125
126
|
}
|
|
127
|
+
interface ZodiacAccount extends TZodiacAccount {
|
|
128
|
+
}
|
|
126
129
|
interface SafeAccount extends IAccount {
|
|
127
130
|
type: 'safe';
|
|
128
131
|
provider?: 'gnosis';
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import { type TAbiInput } from 'dequanto/types/TAbi';
|
|
1
2
|
export declare namespace $types {
|
|
2
3
|
function isFixedArray(type: string): boolean;
|
|
3
4
|
function isDynamicArray(type: string): boolean;
|
|
4
5
|
function isArray(type: string): boolean;
|
|
5
6
|
function isStruct(type: string): boolean;
|
|
6
7
|
function isMapping(type: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the type size in bits, excluding ABI padding.
|
|
10
|
+
* Sums element sizes for fixed arrays and tuple declarations.
|
|
11
|
+
* Returns Infinity for dynamic or unknown types.
|
|
12
|
+
*/
|
|
7
13
|
function sizeOf(type: string): any;
|
|
14
|
+
/** Number of 32-byte ABI words; Infinity for dynamic or unknown types. */
|
|
15
|
+
function wordSizeOf(type: string | TAbiInput): number;
|
|
8
16
|
}
|
|
@@ -25,7 +25,7 @@ export declare class BatchAgent implements ITxWriterAgent {
|
|
|
25
25
|
/**
|
|
26
26
|
* Executes the queued transactions.
|
|
27
27
|
*
|
|
28
|
-
* By default, duplicate transactions are skipped. If the account is Safe or Timelock,
|
|
28
|
+
* By default, duplicate transactions are skipped. If the account is Safe, Zodiac, or Timelock,
|
|
29
29
|
* prepares the corresponding calldata and submits it as a batch transaction.
|
|
30
30
|
*
|
|
31
31
|
* @param options.includeDuplicates Include duplicate transactions in the execution batch.
|
|
@@ -39,6 +39,7 @@ export declare class BatchAgent implements ITxWriterAgent {
|
|
|
39
39
|
print(data?: {
|
|
40
40
|
deployments: Deployments[];
|
|
41
41
|
}): Promise<string>;
|
|
42
|
+
private getAccountKey;
|
|
42
43
|
private executeGroup;
|
|
43
44
|
private executeBatchSafe;
|
|
44
45
|
private executeBatchTimelock;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EoAccount, TAccount, ZodiacAccount } from 'dequanto/models/TAccount';
|
|
2
|
+
import { TxWriter } from '../TxWriter';
|
|
3
|
+
import { ITxWriterAccountAgent } from './TxWriterAccountAgents';
|
|
4
|
+
export declare class ZodiacAgent implements ITxWriterAccountAgent {
|
|
5
|
+
supports(account: TAccount): account is ZodiacAccount;
|
|
6
|
+
process(sender: EoAccount, account: ZodiacAccount, outerWriter: TxWriter): Promise<TxWriter>;
|
|
7
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { EoAccount, Erc4337Account, SafeAccount, TAccount, TimelockAccount } from "dequanto/models/TAccount";
|
|
1
|
+
import { EoAccount, Erc4337Account, SafeAccount, TAccount, TimelockAccount, ZodiacAccount } from "dequanto/models/TAccount";
|
|
2
2
|
export declare namespace $account {
|
|
3
3
|
function getSender(account: TAccount): EoAccount;
|
|
4
|
+
function isZodiac(account: TAccount): account is ZodiacAccount;
|
|
4
5
|
function isSafe(account: TAccount): account is SafeAccount;
|
|
5
6
|
function isErc4337(account: TAccount): account is Erc4337Account;
|
|
6
7
|
function isTimelock(account: TAccount): account is TimelockAccount;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Web3Client } from 'dequanto/clients/Web3Client';
|
|
2
|
+
import { ZodiacAccount } from 'dequanto/models/TAccount';
|
|
3
|
+
import { TEth } from 'dequanto/models/TEth';
|
|
4
|
+
import { config } from 'dequanto/config/Config';
|
|
5
|
+
import { ITxBuilderOptions } from 'dequanto/txs/ITxBuilderOptions';
|
|
6
|
+
import { ITxWriterOptions, TxWriter } from 'dequanto/txs/TxWriter';
|
|
7
|
+
type TCall = Pick<TEth.TxLike, 'to' | 'data' | 'value'>;
|
|
8
|
+
/** Roles v2 execution. Inner values are paid by the avatar, not the operator. */
|
|
9
|
+
export declare class ZodiacTx {
|
|
10
|
+
account: ZodiacAccount;
|
|
11
|
+
client: Web3Client;
|
|
12
|
+
options?: {
|
|
13
|
+
contracts?: typeof config.safe.contracts;
|
|
14
|
+
builder?: ITxBuilderOptions;
|
|
15
|
+
writer?: ITxWriterOptions;
|
|
16
|
+
};
|
|
17
|
+
constructor(account: ZodiacAccount, client: Web3Client, options?: {
|
|
18
|
+
contracts?: typeof config.safe.contracts;
|
|
19
|
+
builder?: ITxBuilderOptions;
|
|
20
|
+
writer?: ITxWriterOptions;
|
|
21
|
+
});
|
|
22
|
+
/** Encode a transaction to the Roles Modifier without submitting it. */
|
|
23
|
+
getTxData(call: TCall, operation?: 0 | 1): TEth.TxLike;
|
|
24
|
+
/** The Roles Modifier must have an unwrapper registered for this MultiSend deployment. */
|
|
25
|
+
getBatchTxData(...calls: TCall[]): TEth.TxLike;
|
|
26
|
+
execute(call: TCall): Promise<TxWriter>;
|
|
27
|
+
executeBatch(...calls: TCall[]): Promise<TxWriter>;
|
|
28
|
+
private send;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
package/package.json
CHANGED
package/skills/dequanto/INDEX.md
CHANGED
|
@@ -24,7 +24,7 @@ Before using an unfamiliar dequanto API, verify the exact signature in `src/` or
|
|
|
24
24
|
| Encode/decode ABI data, hash Solidity values, validate inputs, manipulate hex, work with dates, sign data, or capture promise errors | `$abi`, `$contract`, `$require`, `$hex`, `$date`, `$sig`, `$promise` | `references/utils.md` | `examples/utils.spec.ts` |
|
|
25
25
|
| Read Solidity storage, structs, mappings, arrays, or diamond storage | `SlotsParser`, `SlotsStorage`, generated storage readers | `references/storage.md` | `examples/storage.spec.ts` |
|
|
26
26
|
| Work with tokens and balances | `TokensService`, `TokensServiceFactory`, `TokenTransferService`, generated ERC20 wrappers | `references/tokens-accounts.md` | `examples/token-transfer.spec.ts` |
|
|
27
|
-
| Work with accounts, signing, Safe, or ERC-4337 | `ChainAccountService`, `$sig`, `GnosisSafeHandler`, `SafeTx`, `Erc4337Service`, `Erc4337TxWriter` | `references/safe-erc4337.md`, `references/tokens-accounts.md` | `examples/safe-batch.spec.ts`, `examples/erc4337-userop.spec.ts` |
|
|
27
|
+
| Work with accounts, signing, Safe, Zodiac Roles, or ERC-4337 | `ChainAccountService`, `$sig`, `GnosisSafeHandler`, `SafeTx`, `ZodiacAccount`, `ZodiacTx`, `Erc4337Service`, `Erc4337TxWriter` | `references/safe-erc4337.md`, `references/tokens-accounts.md` | `examples/safe-batch.spec.ts`, `examples/erc4337-userop.spec.ts` |
|
|
28
28
|
| Connect a browser wallet (MetaMask, Rabby, etc.) or build a dApp; request accounts, switch chains, or sign/send txs from browser | `client.wallet`, `EIP6963ProviderFactory`, `WalletClient` | `references/browser.md` | `examples/browser-wallet.spec.ts` |
|
|
29
29
|
| Convert code from ethers or viem habits | Use the dequanto equivalents instead of adding external clients | `references/migration-from-ethers-viem.md` | all examples |
|
|
30
30
|
|
package/skills/dequanto/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dequanto
|
|
3
|
-
description: Use when implementing EVM, blockchain, smart-contract, token, RPC, event-indexing, Safe, ERC-4337, storage, deployment, or ABI work in TypeScript projects that use the dequanto framework. Prefer dequanto APIs over ethers, viem, web3.js, raw JSON-RPC, manual explorer HTTP calls, or hand-written ABI encoding unless the user explicitly asks otherwise.
|
|
3
|
+
description: Use when implementing EVM, blockchain, smart-contract, token, RPC, event-indexing, Safe, Zodiac, ERC-4337, storage, deployment, or ABI work in TypeScript projects that use the dequanto framework. Prefer dequanto APIs over ethers, viem, web3.js, raw JSON-RPC, manual explorer HTTP calls, or hand-written ABI encoding unless the user explicitly asks otherwise.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Dequanto
|
|
@@ -37,6 +37,7 @@ Examples use published `dequanto/...` imports. They retain the repository's `UTe
|
|
|
37
37
|
- EOA with only `address`: the RPC provider/node is responsible for signing.
|
|
38
38
|
- EOA with `key`: dequanto signs directly; encrypted `p1:0x...` keys require the PIN from environment configuration.
|
|
39
39
|
- `safe`: wrap calldata into a Gnosis Safe transaction. Provide `address` and an `operator`; if enough owners/signers are available, dequanto signs and submits on-chain, otherwise it submits to the Gnosis Safe service for later signing.
|
|
40
|
+
- `zodiac`: wrap calldata into a Zodiac Roles Modifier `execTransactionWithRole` call and submit directly on-chain. Provide `platform`, the modifier `address`, an EOA `operator`, and a hex `roleKey`. See `./references/safe-erc4337.md` for batching and configuration.
|
|
40
41
|
- `timelock`: wrap calldata into an OpenZeppelin Timelock transaction and submit it via `operator`.
|
|
41
42
|
- `erc4337`: wrap calldata into an ERC-4337 user operation and submit it via `operator`.
|
|
42
43
|
- Account agents can be chained. For example, a Timelock account can use a Safe account as `operator`, so the initial calldata is wrapped first as Timelock calldata and then as Safe transaction calldata.
|
|
@@ -44,7 +45,7 @@ Examples use published `dequanto/...` imports. They retain the repository's `UTe
|
|
|
44
45
|
- Use `BlockchainExplorerFactory` for explorer ABI, source, creation, transactions, and transfers.
|
|
45
46
|
- Prefer generated `contract.storage` readers and `storage.$set(name, value)` when available; use `SlotsParser` and `SlotsStorage` for manual Solidity layouts.
|
|
46
47
|
- Use `Deployments` for idempotent deployments, proxy deployments, beacon deployments, and verification.
|
|
47
|
-
- Use dequanto account-agent flows when the account type says `safe`, `timelock`, or `erc4337`.
|
|
48
|
+
- Use dequanto account-agent flows when the account type says `safe`, `zodiac`, `timelock`, or `erc4337`.
|
|
48
49
|
- For browser and dApp workflows, use `client.wallet` (`WalletClient`) and `EIP6963ProviderFactory` to discover injected wallets, connect accounts, switch chains, and delegate signing.
|
|
49
50
|
|
|
50
51
|
## Reference Routing
|
|
@@ -62,7 +63,7 @@ Examples use published `dequanto/...` imports. They retain the repository's `UTe
|
|
|
62
63
|
- ABI, hashing, validation, hex, dates, signing, and promise helpers: `./references/utils.md`
|
|
63
64
|
- Solidity storage: `./references/storage.md`
|
|
64
65
|
- Tokens and accounts: `./references/tokens-accounts.md`
|
|
65
|
-
- Safe and ERC-4337: `./references/safe-erc4337.md`
|
|
66
|
+
- Safe, Zodiac Roles, and ERC-4337: `./references/safe-erc4337.md`
|
|
66
67
|
- Browser wallet and dApp integration: `./references/browser.md`
|
|
67
68
|
- Translating ethers/viem habits: `./references/migration-from-ethers-viem.md`
|
|
68
69
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UTest } from 'atma-utest';
|
|
1
2
|
import { Web3ClientFactory } from 'dequanto/clients/Web3ClientFactory';
|
|
2
3
|
import { TokenTransferService } from 'dequanto/tokens/TokenTransferService';
|
|
3
4
|
import { $require } from 'dequanto/utils/$require';
|
|
@@ -8,7 +9,7 @@ import { MockWallet } from '../../../test/eip6963/MockWallet';
|
|
|
8
9
|
// In browser applications (dApps), dequanto discovers injected wallets via EIP-6963 / EIP-1193.
|
|
9
10
|
// When an account is connected to client.wallet, TxWriter routes transactions to the browser wallet
|
|
10
11
|
// for signing and submission without needing a private key.
|
|
11
|
-
UTest({
|
|
12
|
+
UTest.create({
|
|
12
13
|
async 'connect to an injected browser wallet and send a transaction' () {
|
|
13
14
|
const client = await Web3ClientFactory.getAsync('hh:memory');
|
|
14
15
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { UTest } from 'atma-utest';
|
|
1
2
|
import { Config } from 'dequanto/config/Config';
|
|
2
3
|
import { IRpcConfig } from 'dequanto/clients/ClientPool';
|
|
3
4
|
import { Web3ClientFactory } from 'dequanto/clients/Web3ClientFactory';
|
|
4
5
|
import { $require } from 'dequanto/utils/$require';
|
|
5
6
|
import { BlockchainExplorerFactory } from 'dequanto/explorer/BlockchainExplorerFactory';
|
|
6
7
|
|
|
7
|
-
UTest({
|
|
8
|
+
UTest.create({
|
|
8
9
|
async 'load default configuration before RPC actions' () {
|
|
9
10
|
const config = await Config.fetch();
|
|
10
11
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UTest } from 'atma-utest';
|
|
1
2
|
import { Web3ClientFactory } from 'dequanto/clients/Web3ClientFactory';
|
|
2
3
|
import { ContractClassFactory } from 'dequanto/contracts/ContractClassFactory';
|
|
3
4
|
// dequanto ships prebuilt TypeScript clients for all OpenZeppelin contracts.
|
|
@@ -13,7 +14,7 @@ import { $address } from 'dequanto/utils/$address';
|
|
|
13
14
|
const USDC = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' as const;
|
|
14
15
|
const AAVE_POOL = '0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2' as const;
|
|
15
16
|
|
|
16
|
-
UTest({
|
|
17
|
+
UTest.create({
|
|
17
18
|
async 'read data from mainnet using the prebuilt ERC20 contract' () {
|
|
18
19
|
const client = await Web3ClientFactory.getAsync('eth');
|
|
19
20
|
const usdc = new ERC20(USDC, client);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UTest } from 'atma-utest';
|
|
1
2
|
import { Web3ClientFactory } from 'dequanto/clients/Web3ClientFactory';
|
|
2
3
|
import { ContractReader } from 'dequanto/contracts/ContractReader';
|
|
3
4
|
import { ERC20 } from 'dequanto/prebuilt/openzeppelin/ERC20';
|
|
@@ -9,7 +10,7 @@ import { $require } from 'dequanto/utils/$require';
|
|
|
9
10
|
|
|
10
11
|
const USDC = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' as const;
|
|
11
12
|
|
|
12
|
-
UTest({
|
|
13
|
+
UTest.create({
|
|
13
14
|
async 'submit a contract write transaction' () {
|
|
14
15
|
// Use getAsync(platform) with a real funded account to submit the same write on mainnet
|
|
15
16
|
const client = await Web3ClientFactory.getAsync('hh:memory:eth');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UTest } from 'atma-utest';
|
|
1
2
|
import { Web3ClientFactory } from 'dequanto/clients/Web3ClientFactory';
|
|
2
3
|
import { Deployments } from 'dequanto/contracts/deploy/Deployments';
|
|
3
4
|
import { Generator } from 'dequanto/gen/Generator';
|
|
@@ -12,7 +13,7 @@ import { File } from 'atma-io';
|
|
|
12
13
|
// import { FooContract } from '0xc/hardhat/FooContract/FooContract';
|
|
13
14
|
declare const include: any;
|
|
14
15
|
|
|
15
|
-
UTest({
|
|
16
|
+
UTest.create({
|
|
16
17
|
async 'deploy a generated contract class with Deployments.ensure' () {
|
|
17
18
|
const { client, deployer, FooContract } = await getContractClass();
|
|
18
19
|
const deployments = new Deployments(client, deployer, {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UTest } from 'atma-utest';
|
|
1
2
|
import { Web3ClientFactory } from 'dequanto/clients/Web3ClientFactory';
|
|
2
3
|
import { BlockchainExplorerFactory } from 'dequanto/explorer/BlockchainExplorerFactory';
|
|
3
4
|
import { Erc4337Service } from 'dequanto/erc4337/Erc4337Service';
|
|
@@ -6,7 +7,7 @@ import { $address } from 'dequanto/utils/$address';
|
|
|
6
7
|
import { $erc4337 } from 'dequanto/erc4337/utils/$erc4337';
|
|
7
8
|
import { $require } from 'dequanto/utils/$require';
|
|
8
9
|
|
|
9
|
-
UTest({
|
|
10
|
+
UTest.create({
|
|
10
11
|
async 'hash a UserOperation and create an ERC-4337 service' () {
|
|
11
12
|
const client = await Web3ClientFactory.getAsync('eth');
|
|
12
13
|
const explorer = await BlockchainExplorerFactory.getAsync('eth');
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { UTest } from 'atma-utest';
|
|
1
2
|
import { BlockchainExplorerFactory } from 'dequanto/explorer/BlockchainExplorerFactory';
|
|
2
3
|
import { $address } from 'dequanto/utils/$address';
|
|
3
4
|
import { $require } from 'dequanto/utils/$require';
|
|
4
5
|
|
|
5
|
-
UTest({
|
|
6
|
+
UTest.create({
|
|
6
7
|
async 'fetch stable USDC ABI and source from configured Ethereum explorer' () {
|
|
7
8
|
const explorer = await BlockchainExplorerFactory.getAsync('eth');
|
|
8
9
|
const address = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { UTest } from 'atma-utest';
|
|
1
2
|
import { Generator } from 'dequanto/gen/Generator';
|
|
2
3
|
import { $require } from 'dequanto/utils/$require';
|
|
3
4
|
import { File } from 'atma-io';
|
|
4
5
|
|
|
5
6
|
// Generator is the low-level API for creating contract classes programmatically.
|
|
6
7
|
// Prefer 0xweb install for third-party contracts and @0xweb/hardhat for local Hardhat contracts.
|
|
7
|
-
UTest({
|
|
8
|
+
UTest.create({
|
|
8
9
|
async 'generate a typed contract class from a fixture artifact' () {
|
|
9
10
|
const output = './test/tmp/ai-examples/hardhat/';
|
|
10
11
|
const gen = new Generator({
|