@prb/effect-evm 1.0.0-beta.4 → 1.0.0-beta.6
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/DOCS.md +13 -0
- package/README.md +1 -0
- package/dist/constants/index.d.ts +0 -4
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +0 -4
- package/dist/constants/index.js.map +1 -1
- package/dist/contract/pipeline/internal/core.d.ts +2 -2
- package/dist/contract/pipeline/internal/core.d.ts.map +1 -1
- package/dist/contract/pipeline/internal/core.js.map +1 -1
- package/dist/contract/pipeline/internal/receipt.d.ts +2 -2
- package/dist/contract/pipeline/internal/receipt.d.ts.map +1 -1
- package/dist/contract/pipeline/internal/receipt.js +1 -1
- package/dist/contract/pipeline/internal/receipt.js.map +1 -1
- package/dist/contract/pipeline/service.d.ts +3 -3
- package/dist/contract/pipeline/service.d.ts.map +1 -1
- package/dist/contract/pipeline/service.js.map +1 -1
- package/dist/contract/pipeline/types.d.ts +2 -2
- package/dist/contract/pipeline/types.d.ts.map +1 -1
- package/dist/contract/pipeline/types.js.map +1 -1
- package/dist/contract/pipeline/write-and-track.js +1 -1
- package/dist/contract/pipeline/write-and-track.js.map +1 -1
- package/dist/contract/pipeline/write-and-wait.d.ts +1 -1
- package/dist/contract/pipeline/write-and-wait.d.ts.map +1 -1
- package/dist/core/errors/transaction.d.ts +7 -7
- package/dist/core/errors/transaction.d.ts.map +1 -1
- package/dist/core/errors/transaction.js +2 -2
- package/dist/core/errors/transaction.js.map +1 -1
- package/dist/core/errors/viem-mapper.d.ts +3 -3
- package/dist/core/errors/viem-mapper.d.ts.map +1 -1
- package/dist/core/errors/viem-mapper.js +3 -3
- package/dist/core/errors/viem-mapper.js.map +1 -1
- package/dist/deploy/service.d.ts +3 -3
- package/dist/deploy/service.d.ts.map +1 -1
- package/dist/deploy/service.js.map +1 -1
- package/dist/eip7702/errors.d.ts +3 -3
- package/dist/eip7702/errors.d.ts.map +1 -1
- package/dist/eip7702/errors.js +1 -1
- package/dist/eip7702/errors.js.map +1 -1
- package/dist/eip7702/service.d.ts +8 -8
- package/dist/eip7702/service.d.ts.map +1 -1
- package/dist/eip7702/service.js +2 -2
- package/dist/eip7702/service.js.map +1 -1
- package/dist/react-hooks/index.d.ts +0 -4
- package/dist/react-hooks/index.d.ts.map +1 -1
- package/dist/react-hooks/index.js +0 -4
- package/dist/react-hooks/index.js.map +1 -1
- package/dist/subscriptions/pending-tx.d.ts +1 -1
- package/dist/subscriptions/pending-tx.d.ts.map +1 -1
- package/dist/subscriptions/pending-tx.js +1 -1
- package/dist/subscriptions/pending-tx.js.map +1 -1
- package/dist/subscriptions/service.d.ts +2 -2
- package/dist/subscriptions/service.d.ts.map +1 -1
- package/dist/subscriptions/service.js +4 -4
- package/dist/subscriptions/service.js.map +1 -1
- package/dist/telemetry/tracer.d.ts +2 -2
- package/dist/telemetry/tracer.js +2 -2
- package/dist/telemetry/tracer.js.map +1 -1
- package/dist/testing-kit/mock-subscription-service.d.ts +2 -2
- package/dist/testing-kit/mock-subscription-service.d.ts.map +1 -1
- package/dist/testing-kit/mock-subscription-service.js +5 -5
- package/dist/testing-kit/mock-subscription-service.js.map +1 -1
- package/dist/testing-kit/mock-transfer-service.d.ts +3 -3
- package/dist/testing-kit/mock-transfer-service.d.ts.map +1 -1
- package/dist/testing-kit/mock-transfer-service.js.map +1 -1
- package/dist/transfer/service.d.ts +3 -3
- package/dist/transfer/service.d.ts.map +1 -1
- package/dist/transfer/service.js +3 -3
- package/dist/transfer/service.js.map +1 -1
- package/dist/tx/manager.d.ts +2 -2
- package/dist/tx/manager.d.ts.map +1 -1
- package/dist/tx/manager.js +5 -5
- package/dist/tx/manager.js.map +1 -1
- package/dist/tx/manager.test.integration.js +4 -4
- package/dist/tx/manager.test.integration.js.map +1 -1
- package/dist/tx/replacement.d.ts +3 -3
- package/dist/tx/replacement.d.ts.map +1 -1
- package/dist/tx/replacement.js +3 -3
- package/dist/tx/replacement.js.map +1 -1
- package/dist/tx/tracker.d.ts +6 -6
- package/dist/tx/tracker.d.ts.map +1 -1
- package/dist/tx/tracker.js +9 -9
- package/dist/tx/tracker.js.map +1 -1
- package/dist/types/params.d.ts +1 -1
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/params.js.map +1 -1
- package/dist/wallet/errors.d.ts +3 -3
- package/dist/wallet/errors.d.ts.map +1 -1
- package/dist/wallet/errors.js +1 -1
- package/dist/wallet/errors.js.map +1 -1
- package/dist/wallet/operations.d.ts +2 -2
- package/dist/wallet/operations.d.ts.map +1 -1
- package/dist/wallet/operations.js +2 -2
- package/dist/wallet/operations.js.map +1 -1
- package/dist/wallet/service.d.ts +2 -2
- package/dist/wallet/service.d.ts.map +1 -1
- package/dist/wallet/service.js.map +1 -1
- package/package.json +1 -6
- package/dist/react-hooks/safe-origins.d.ts +0 -8
- package/dist/react-hooks/safe-origins.d.ts.map +0 -1
- package/dist/react-hooks/safe-origins.js +0 -124
- package/dist/react-hooks/safe-origins.js.map +0 -1
- package/dist/react-hooks/use-is-host-safe-multisig.d.ts +0 -2
- package/dist/react-hooks/use-is-host-safe-multisig.d.ts.map +0 -1
- package/dist/react-hooks/use-is-host-safe-multisig.js +0 -16
- package/dist/react-hooks/use-is-host-safe-multisig.js.map +0 -1
- package/dist/react-hooks/use-is-wallet-safe-multisig.d.ts +0 -2
- package/dist/react-hooks/use-is-wallet-safe-multisig.d.ts.map +0 -1
- package/dist/react-hooks/use-is-wallet-safe-multisig.js +0 -24
- package/dist/react-hooks/use-is-wallet-safe-multisig.js.map +0 -1
- package/dist/react-hooks/use-safe-context.d.ts +0 -2
- package/dist/react-hooks/use-safe-context.d.ts.map +0 -1
- package/dist/react-hooks/use-safe-context.js +0 -41
- package/dist/react-hooks/use-safe-context.js.map +0 -1
- package/dist/safe/adapter.d.ts +0 -9
- package/dist/safe/adapter.d.ts.map +0 -1
- package/dist/safe/adapter.js +0 -13
- package/dist/safe/adapter.js.map +0 -1
- package/dist/safe/detection.d.ts +0 -26
- package/dist/safe/detection.d.ts.map +0 -1
- package/dist/safe/detection.js +0 -102
- package/dist/safe/detection.js.map +0 -1
- package/dist/safe/detection.test.integration.d.ts +0 -2
- package/dist/safe/detection.test.integration.d.ts.map +0 -1
- package/dist/safe/detection.test.integration.js +0 -92
- package/dist/safe/detection.test.integration.js.map +0 -1
- package/dist/safe/errors.d.ts +0 -79
- package/dist/safe/errors.d.ts.map +0 -1
- package/dist/safe/errors.js +0 -34
- package/dist/safe/errors.js.map +0 -1
- package/dist/safe/index.d.ts +0 -8
- package/dist/safe/index.d.ts.map +0 -1
- package/dist/safe/index.js +0 -6
- package/dist/safe/index.js.map +0 -1
- package/dist/safe/live.d.ts +0 -8
- package/dist/safe/live.d.ts.map +0 -1
- package/dist/safe/live.js +0 -250
- package/dist/safe/live.js.map +0 -1
- package/dist/safe/service.d.ts +0 -26
- package/dist/safe/service.d.ts.map +0 -1
- package/dist/safe/service.js +0 -4
- package/dist/safe/service.js.map +0 -1
- package/dist/safe/service.test.integration.d.ts +0 -2
- package/dist/safe/service.test.integration.d.ts.map +0 -1
- package/dist/safe/service.test.integration.js +0 -173
- package/dist/safe/service.test.integration.js.map +0 -1
- package/dist/safe/simulation/abis.d.ts +0 -73
- package/dist/safe/simulation/abis.d.ts.map +0 -1
- package/dist/safe/simulation/abis.js +0 -61
- package/dist/safe/simulation/abis.js.map +0 -1
- package/dist/safe/simulation/addresses.d.ts +0 -4
- package/dist/safe/simulation/addresses.d.ts.map +0 -1
- package/dist/safe/simulation/addresses.js +0 -54
- package/dist/safe/simulation/addresses.js.map +0 -1
- package/dist/safe/simulation/encoding.d.ts +0 -16
- package/dist/safe/simulation/encoding.d.ts.map +0 -1
- package/dist/safe/simulation/encoding.js +0 -36
- package/dist/safe/simulation/encoding.js.map +0 -1
- package/dist/safe/simulation/errors.d.ts +0 -56
- package/dist/safe/simulation/errors.d.ts.map +0 -1
- package/dist/safe/simulation/errors.js +0 -37
- package/dist/safe/simulation/errors.js.map +0 -1
- package/dist/safe/simulation/index.d.ts +0 -7
- package/dist/safe/simulation/index.d.ts.map +0 -1
- package/dist/safe/simulation/index.js +0 -6
- package/dist/safe/simulation/index.js.map +0 -1
- package/dist/safe/simulation/internal/calldata/calldata.d.ts +0 -5
- package/dist/safe/simulation/internal/calldata/calldata.d.ts.map +0 -1
- package/dist/safe/simulation/internal/calldata/calldata.js +0 -17
- package/dist/safe/simulation/internal/calldata/calldata.js.map +0 -1
- package/dist/safe/simulation/internal/calldata/index.d.ts +0 -2
- package/dist/safe/simulation/internal/calldata/index.d.ts.map +0 -1
- package/dist/safe/simulation/internal/calldata/index.js +0 -2
- package/dist/safe/simulation/internal/calldata/index.js.map +0 -1
- package/dist/safe/simulation/internal/contracts/contracts.d.ts +0 -5
- package/dist/safe/simulation/internal/contracts/contracts.d.ts.map +0 -1
- package/dist/safe/simulation/internal/contracts/contracts.js +0 -25
- package/dist/safe/simulation/internal/contracts/contracts.js.map +0 -1
- package/dist/safe/simulation/internal/contracts/index.d.ts +0 -2
- package/dist/safe/simulation/internal/contracts/index.d.ts.map +0 -1
- package/dist/safe/simulation/internal/contracts/index.js +0 -2
- package/dist/safe/simulation/internal/contracts/index.js.map +0 -1
- package/dist/safe/simulation/internal/evaluation/evaluation.d.ts +0 -6
- package/dist/safe/simulation/internal/evaluation/evaluation.d.ts.map +0 -1
- package/dist/safe/simulation/internal/evaluation/evaluation.js +0 -20
- package/dist/safe/simulation/internal/evaluation/evaluation.js.map +0 -1
- package/dist/safe/simulation/internal/evaluation/index.d.ts +0 -2
- package/dist/safe/simulation/internal/evaluation/index.d.ts.map +0 -1
- package/dist/safe/simulation/internal/evaluation/index.js +0 -2
- package/dist/safe/simulation/internal/evaluation/index.js.map +0 -1
- package/dist/safe/simulation/internal/execution/execution.d.ts +0 -9
- package/dist/safe/simulation/internal/execution/execution.d.ts.map +0 -1
- package/dist/safe/simulation/internal/execution/execution.js +0 -65
- package/dist/safe/simulation/internal/execution/execution.js.map +0 -1
- package/dist/safe/simulation/internal/execution/index.d.ts +0 -2
- package/dist/safe/simulation/internal/execution/index.d.ts.map +0 -1
- package/dist/safe/simulation/internal/execution/index.js +0 -2
- package/dist/safe/simulation/internal/execution/index.js.map +0 -1
- package/dist/safe/simulation/internal/limits/index.d.ts +0 -2
- package/dist/safe/simulation/internal/limits/index.d.ts.map +0 -1
- package/dist/safe/simulation/internal/limits/index.js +0 -2
- package/dist/safe/simulation/internal/limits/index.js.map +0 -1
- package/dist/safe/simulation/internal/limits/limits.d.ts +0 -5
- package/dist/safe/simulation/internal/limits/limits.d.ts.map +0 -1
- package/dist/safe/simulation/internal/limits/limits.js +0 -18
- package/dist/safe/simulation/internal/limits/limits.js.map +0 -1
- package/dist/safe/simulation/internal/types/index.d.ts +0 -2
- package/dist/safe/simulation/internal/types/index.d.ts.map +0 -1
- package/dist/safe/simulation/internal/types/index.js +0 -2
- package/dist/safe/simulation/internal/types/index.js.map +0 -1
- package/dist/safe/simulation/internal/types/types.d.ts +0 -11
- package/dist/safe/simulation/internal/types/types.d.ts.map +0 -1
- package/dist/safe/simulation/internal/types/types.js +0 -2
- package/dist/safe/simulation/internal/types/types.js.map +0 -1
- package/dist/safe/simulation/internal/validation/index.d.ts +0 -2
- package/dist/safe/simulation/internal/validation/index.d.ts.map +0 -1
- package/dist/safe/simulation/internal/validation/index.js +0 -2
- package/dist/safe/simulation/internal/validation/index.js.map +0 -1
- package/dist/safe/simulation/internal/validation/validation.d.ts +0 -5
- package/dist/safe/simulation/internal/validation/validation.d.ts.map +0 -1
- package/dist/safe/simulation/internal/validation/validation.js +0 -27
- package/dist/safe/simulation/internal/validation/validation.js.map +0 -1
- package/dist/safe/simulation/service.d.ts +0 -14
- package/dist/safe/simulation/service.d.ts.map +0 -1
- package/dist/safe/simulation/service.js +0 -25
- package/dist/safe/simulation/service.js.map +0 -1
- package/dist/safe/simulation/types.d.ts +0 -20
- package/dist/safe/simulation/types.d.ts.map +0 -1
- package/dist/safe/simulation/types.js +0 -2
- package/dist/safe/simulation/types.js.map +0 -1
- package/dist/safe/types.d.ts +0 -61
- package/dist/safe/types.d.ts.map +0 -1
- package/dist/safe/types.js +0 -2
- package/dist/safe/types.js.map +0 -1
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "@effect/vitest";
|
|
2
|
-
import { Effect, Layer, Option } from "effect";
|
|
3
|
-
import { MIN_TX_GAS } from "../constants/index.js";
|
|
4
|
-
import { TEST_ADDRESS, TEST_CHAIN_ID, TEST_TX_HASH } from "../testing-kit/index.js";
|
|
5
|
-
import { SafeAppsService } from "./service.js";
|
|
6
|
-
const TEST_SAFE_ADDRESS = TEST_ADDRESS;
|
|
7
|
-
const TEST_SAFE_TX_HASH = "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";
|
|
8
|
-
const TEST_MESSAGE_HASH = "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890";
|
|
9
|
-
const TEST_SIGNATURE = "0xsignature";
|
|
10
|
-
const TEST_RECEIPT = {
|
|
11
|
-
blockHash: "0xblock",
|
|
12
|
-
blockNumber: 123n,
|
|
13
|
-
contractAddress: null,
|
|
14
|
-
cumulativeGasUsed: MIN_TX_GAS,
|
|
15
|
-
effectiveGasPrice: 1n,
|
|
16
|
-
from: "0xfrom",
|
|
17
|
-
gasUsed: MIN_TX_GAS,
|
|
18
|
-
logs: [],
|
|
19
|
-
logsBloom: "0x",
|
|
20
|
-
status: "success",
|
|
21
|
-
to: "0xto",
|
|
22
|
-
transactionHash: TEST_TX_HASH,
|
|
23
|
-
transactionIndex: 0,
|
|
24
|
-
type: "0x2",
|
|
25
|
-
};
|
|
26
|
-
const makeMockSafeAppsService = (config) => {
|
|
27
|
-
const defaultInfo = {
|
|
28
|
-
chainId: TEST_CHAIN_ID,
|
|
29
|
-
safeAddress: TEST_SAFE_ADDRESS,
|
|
30
|
-
};
|
|
31
|
-
return Layer.succeed(SafeAppsService, SafeAppsService.of({
|
|
32
|
-
enableOffchainSigning: () => Effect.void,
|
|
33
|
-
getInfo: () => Effect.succeed(config.getInfoResult ?? defaultInfo),
|
|
34
|
-
getOffchainSignature: () => Effect.succeed(config.offchainSignature ?? Option.none()),
|
|
35
|
-
getTransaction: () => Effect.succeed(config.getTxResult ?? {
|
|
36
|
-
status: "AWAITING_EXECUTION",
|
|
37
|
-
txHash: Option.some(TEST_TX_HASH),
|
|
38
|
-
}),
|
|
39
|
-
pollOffchainSignature: (messageHash) => Effect.succeed({ messageHash, signature: TEST_SIGNATURE }),
|
|
40
|
-
sendTransactions: () => Effect.succeed({
|
|
41
|
-
chainId: TEST_CHAIN_ID,
|
|
42
|
-
safeAddress: TEST_SAFE_ADDRESS,
|
|
43
|
-
safeTxHash: config.sendTxResult?.safeTxHash ?? TEST_SAFE_TX_HASH,
|
|
44
|
-
}),
|
|
45
|
-
signTypedData: () => Effect.succeed(config.signTypedDataResult ?? {
|
|
46
|
-
_tag: "Onchain",
|
|
47
|
-
safeTxHash: TEST_SAFE_TX_HASH,
|
|
48
|
-
}),
|
|
49
|
-
waitForTransactionReceipt: (safeTxHash) => Effect.succeed({
|
|
50
|
-
chainId: TEST_CHAIN_ID,
|
|
51
|
-
onchainHash: TEST_TX_HASH,
|
|
52
|
-
receipt: TEST_RECEIPT,
|
|
53
|
-
safeAddress: TEST_SAFE_ADDRESS,
|
|
54
|
-
safeTxHash,
|
|
55
|
-
}),
|
|
56
|
-
}));
|
|
57
|
-
};
|
|
58
|
-
describe("SafeAppsService", () => {
|
|
59
|
-
describe("getInfo", () => {
|
|
60
|
-
it.effect("returns Safe info with address and chainId", () => Effect.gen(function* () {
|
|
61
|
-
const service = yield* SafeAppsService;
|
|
62
|
-
const info = yield* service.getInfo();
|
|
63
|
-
expect(info.safeAddress).toBe(TEST_SAFE_ADDRESS);
|
|
64
|
-
expect(info.chainId).toBe(TEST_CHAIN_ID);
|
|
65
|
-
}).pipe(Effect.provide(makeMockSafeAppsService({}))));
|
|
66
|
-
});
|
|
67
|
-
describe("sendTransactions", () => {
|
|
68
|
-
it.effect("returns safeTxHash with safeAddress and chainId", () => Effect.gen(function* () {
|
|
69
|
-
const service = yield* SafeAppsService;
|
|
70
|
-
const result = yield* service.sendTransactions([
|
|
71
|
-
{ data: "0x", to: TEST_ADDRESS, value: 0n },
|
|
72
|
-
]);
|
|
73
|
-
expect(result.safeTxHash).toBe(TEST_SAFE_TX_HASH);
|
|
74
|
-
expect(result.safeAddress).toBe(TEST_SAFE_ADDRESS);
|
|
75
|
-
expect(result.chainId).toBe(TEST_CHAIN_ID);
|
|
76
|
-
}).pipe(Effect.provide(makeMockSafeAppsService({}))));
|
|
77
|
-
});
|
|
78
|
-
describe("getTransaction", () => {
|
|
79
|
-
it.effect("returns txHash as Option when executed", () => Effect.gen(function* () {
|
|
80
|
-
const service = yield* SafeAppsService;
|
|
81
|
-
const result = yield* service.getTransaction(TEST_SAFE_TX_HASH);
|
|
82
|
-
expect(Option.isSome(result.txHash)).toBe(true);
|
|
83
|
-
if (Option.isSome(result.txHash)) {
|
|
84
|
-
expect(result.txHash.value).toBe(TEST_TX_HASH);
|
|
85
|
-
}
|
|
86
|
-
}).pipe(Effect.provide(makeMockSafeAppsService({}))));
|
|
87
|
-
it.effect("returns Option.none when not yet executed", () => Effect.gen(function* () {
|
|
88
|
-
const service = yield* SafeAppsService;
|
|
89
|
-
const result = yield* service.getTransaction(TEST_SAFE_TX_HASH);
|
|
90
|
-
expect(Option.isNone(result.txHash)).toBe(true);
|
|
91
|
-
expect(result.status).toBe("AWAITING_CONFIRMATIONS");
|
|
92
|
-
}).pipe(Effect.provide(makeMockSafeAppsService({
|
|
93
|
-
getTxResult: {
|
|
94
|
-
status: "AWAITING_CONFIRMATIONS",
|
|
95
|
-
txHash: Option.none(),
|
|
96
|
-
},
|
|
97
|
-
}))));
|
|
98
|
-
});
|
|
99
|
-
describe("waitForTransactionReceipt", () => {
|
|
100
|
-
it.effect("returns SafeTxResult with receipt", () => Effect.gen(function* () {
|
|
101
|
-
const service = yield* SafeAppsService;
|
|
102
|
-
const result = yield* service.waitForTransactionReceipt(TEST_SAFE_TX_HASH);
|
|
103
|
-
expect(result.safeTxHash).toBe(TEST_SAFE_TX_HASH);
|
|
104
|
-
expect(result.onchainHash).toBe(TEST_TX_HASH);
|
|
105
|
-
expect(result.receipt.status).toBe("success");
|
|
106
|
-
expect(result.safeAddress).toBe(TEST_SAFE_ADDRESS);
|
|
107
|
-
expect(result.chainId).toBe(TEST_CHAIN_ID);
|
|
108
|
-
}).pipe(Effect.provide(makeMockSafeAppsService({}))));
|
|
109
|
-
});
|
|
110
|
-
describe("signTypedData", () => {
|
|
111
|
-
it.effect("returns Onchain variant for on-chain signing", () => Effect.gen(function* () {
|
|
112
|
-
const service = yield* SafeAppsService;
|
|
113
|
-
const result = yield* service.signTypedData({
|
|
114
|
-
domain: { chainId: 1, name: "Test" },
|
|
115
|
-
message: { value: "test" },
|
|
116
|
-
types: { Test: [{ name: "value", type: "string" }] },
|
|
117
|
-
});
|
|
118
|
-
expect(result._tag).toBe("Onchain");
|
|
119
|
-
if (result._tag === "Onchain") {
|
|
120
|
-
expect(result.safeTxHash).toBe(TEST_SAFE_TX_HASH);
|
|
121
|
-
}
|
|
122
|
-
}).pipe(Effect.provide(makeMockSafeAppsService({}))));
|
|
123
|
-
it.effect("returns Offchain variant for off-chain signing", () => Effect.gen(function* () {
|
|
124
|
-
const service = yield* SafeAppsService;
|
|
125
|
-
const result = yield* service.signTypedData({
|
|
126
|
-
domain: { chainId: 1, name: "Test" },
|
|
127
|
-
message: { value: "test" },
|
|
128
|
-
types: { Test: [{ name: "value", type: "string" }] },
|
|
129
|
-
});
|
|
130
|
-
expect(result._tag).toBe("Offchain");
|
|
131
|
-
if (result._tag === "Offchain") {
|
|
132
|
-
expect(result.messageHash).toBe(TEST_MESSAGE_HASH);
|
|
133
|
-
}
|
|
134
|
-
}).pipe(Effect.provide(makeMockSafeAppsService({
|
|
135
|
-
signTypedDataResult: {
|
|
136
|
-
_tag: "Offchain",
|
|
137
|
-
messageHash: TEST_MESSAGE_HASH,
|
|
138
|
-
},
|
|
139
|
-
}))));
|
|
140
|
-
});
|
|
141
|
-
describe("getOffchainSignature", () => {
|
|
142
|
-
it.effect("returns Option.none when signature not yet available", () => Effect.gen(function* () {
|
|
143
|
-
const service = yield* SafeAppsService;
|
|
144
|
-
const result = yield* service.getOffchainSignature(TEST_MESSAGE_HASH);
|
|
145
|
-
expect(Option.isNone(result)).toBe(true);
|
|
146
|
-
}).pipe(Effect.provide(makeMockSafeAppsService({}))));
|
|
147
|
-
it.effect("returns Option.some when signature available", () => Effect.gen(function* () {
|
|
148
|
-
const service = yield* SafeAppsService;
|
|
149
|
-
const result = yield* service.getOffchainSignature(TEST_MESSAGE_HASH);
|
|
150
|
-
expect(Option.isSome(result)).toBe(true);
|
|
151
|
-
if (Option.isSome(result)) {
|
|
152
|
-
expect(result.value).toBe(TEST_SIGNATURE);
|
|
153
|
-
}
|
|
154
|
-
}).pipe(Effect.provide(makeMockSafeAppsService({
|
|
155
|
-
offchainSignature: Option.some(TEST_SIGNATURE),
|
|
156
|
-
}))));
|
|
157
|
-
});
|
|
158
|
-
describe("pollOffchainSignature", () => {
|
|
159
|
-
it.effect("returns signature when available", () => Effect.gen(function* () {
|
|
160
|
-
const service = yield* SafeAppsService;
|
|
161
|
-
const result = yield* service.pollOffchainSignature(TEST_MESSAGE_HASH);
|
|
162
|
-
expect(result.messageHash).toBe(TEST_MESSAGE_HASH);
|
|
163
|
-
expect(result.signature).toBe(TEST_SIGNATURE);
|
|
164
|
-
}).pipe(Effect.provide(makeMockSafeAppsService({}))));
|
|
165
|
-
});
|
|
166
|
-
describe("enableOffchainSigning", () => {
|
|
167
|
-
it.effect("completes without error", () => Effect.gen(function* () {
|
|
168
|
-
const service = yield* SafeAppsService;
|
|
169
|
-
yield* service.enableOffchainSigning();
|
|
170
|
-
}).pipe(Effect.provide(makeMockSafeAppsService({}))));
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
//# sourceMappingURL=service.test.integration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service.test.integration.js","sourceRoot":"","sources":["../../src/safe/service.test.integration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAI/C,MAAM,iBAAiB,GAAG,YAAY,CAAC;AACvC,MAAM,iBAAiB,GACrB,oEAA4E,CAAC;AAC/E,MAAM,iBAAiB,GACrB,oEAA2E,CAAC;AAC9E,MAAM,cAAc,GAAG,aAAoB,CAAC;AAE5C,MAAM,YAAY,GAAuB;IACvC,SAAS,EAAE,SAAS;IACpB,WAAW,EAAE,IAAI;IACjB,eAAe,EAAE,IAAI;IACrB,iBAAiB,EAAE,UAAU;IAC7B,iBAAiB,EAAE,EAAE;IACrB,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,UAAU;IACnB,IAAI,EAAE,EAAE;IACR,SAAS,EAAE,IAAI;IACf,MAAM,EAAE,SAAS;IACjB,EAAE,EAAE,MAAM;IACV,eAAe,EAAE,YAAY;IAC7B,gBAAgB,EAAE,CAAC;IACnB,IAAI,EAAE,KAAK;CACZ,CAAC;AAGF,MAAM,uBAAuB,GAAG,CAAC,MAQhC,EAAE,EAAE;IACH,MAAM,WAAW,GAAa;QAC5B,OAAO,EAAE,aAAa;QACtB,WAAW,EAAE,iBAAiB;KAC/B,CAAC;IAEF,OAAO,KAAK,CAAC,OAAO,CAClB,eAAe,EACf,eAAe,CAAC,EAAE,CAAC;QACjB,q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esContent":["import { describe, expect, it } from \"@effect/vitest\";\nimport { Effect, Layer, Option } from \"effect\";\nimport type { Hash, Hex, TransactionReceipt } from \"viem\";\nimport { MIN_TX_GAS } from \"@/src/constants/index.js\";\nimport { TEST_ADDRESS, TEST_CHAIN_ID, TEST_TX_HASH } from \"@/src/testing-kit/index.js\";\nimport { SafeAppsService } from \"./service.js\";\nimport type { SafeInfo } from \"./types.js\";\n\n// Test fixtures\nconst TEST_SAFE_ADDRESS = TEST_ADDRESS;\nconst TEST_SAFE_TX_HASH =\n \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\" as Hash;\nconst TEST_MESSAGE_HASH =\n \"0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\" as Hex;\nconst TEST_SIGNATURE = \"0xsignature\" as Hex;\n\nconst TEST_RECEIPT: TransactionReceipt = {\n blockHash: \"0xblock\",\n blockNumber: 123n,\n contractAddress: null,\n cumulativeGasUsed: MIN_TX_GAS,\n effectiveGasPrice: 1n,\n from: \"0xfrom\",\n gasUsed: MIN_TX_GAS,\n logs: [],\n logsBloom: \"0x\",\n status: \"success\",\n to: \"0xto\",\n transactionHash: TEST_TX_HASH,\n transactionIndex: 0,\n type: \"0x2\",\n};\n\n// Mock SafeAppsService for testing without actual SDK\nconst makeMockSafeAppsService = (config: {\n getInfoResult?: SafeInfo;\n sendTxResult?: { safeTxHash: Hash };\n getTxResult?: { txHash: Option.Option<Hash>; status: string };\n signTypedDataResult?:\n | { _tag: \"Offchain\"; messageHash: Hex }\n | { _tag: \"Onchain\"; safeTxHash: Hash };\n offchainSignature?: Option.Option<Hex>;\n}) => {\n const defaultInfo: SafeInfo = {\n chainId: TEST_CHAIN_ID,\n safeAddress: TEST_SAFE_ADDRESS,\n };\n\n return Layer.succeed(\n SafeAppsService,\n SafeAppsService.of({\n enableOffchainSigning: () => Effect.void,\n getInfo: () => Effect.succeed(config.getInfoResult ?? defaultInfo),\n getOffchainSignature: () => Effect.succeed(config.offchainSignature ?? Option.none()),\n getTransaction: () =>\n Effect.succeed(\n config.getTxResult ?? {\n status: \"AWAITING_EXECUTION\",\n txHash: Option.some(TEST_TX_HASH),\n }\n ),\n pollOffchainSignature: (messageHash) =>\n Effect.succeed({ messageHash, signature: TEST_SIGNATURE }),\n sendTransactions: () =>\n Effect.succeed({\n chainId: TEST_CHAIN_ID,\n safeAddress: TEST_SAFE_ADDRESS,\n safeTxHash: config.sendTxResult?.safeTxHash ?? TEST_SAFE_TX_HASH,\n }),\n signTypedData: () =>\n Effect.succeed(\n config.signTypedDataResult ?? {\n _tag: \"Onchain\" as const,\n safeTxHash: TEST_SAFE_TX_HASH,\n }\n ),\n waitForTransactionReceipt: (safeTxHash) =>\n Effect.succeed({\n chainId: TEST_CHAIN_ID,\n onchainHash: TEST_TX_HASH,\n receipt: TEST_RECEIPT,\n safeAddress: TEST_SAFE_ADDRESS,\n safeTxHash,\n }),\n })\n );\n};\n\ndescribe(\"SafeAppsService\", () => {\n describe(\"getInfo\", () => {\n it.effect(\"returns Safe info with address and chainId\", () =>\n Effect.gen(function* () {\n const service = yield* SafeAppsService;\n const info = yield* service.getInfo();\n\n expect(info.safeAddress).toBe(TEST_SAFE_ADDRESS);\n expect(info.chainId).toBe(TEST_CHAIN_ID);\n }).pipe(Effect.provide(makeMockSafeAppsService({})))\n );\n });\n\n describe(\"sendTransactions\", () => {\n it.effect(\"returns safeTxHash with safeAddress and chainId\", () =>\n Effect.gen(function* () {\n const service = yield* SafeAppsService;\n const result = yield* service.sendTransactions([\n { data: \"0x\", to: TEST_ADDRESS, value: 0n },\n ]);\n\n expect(result.safeTxHash).toBe(TEST_SAFE_TX_HASH);\n expect(result.safeAddress).toBe(TEST_SAFE_ADDRESS);\n expect(result.chainId).toBe(TEST_CHAIN_ID);\n }).pipe(Effect.provide(makeMockSafeAppsService({})))\n );\n });\n\n describe(\"getTransaction\", () => {\n it.effect(\"returns txHash as Option when executed\", () =>\n Effect.gen(function* () {\n const service = yield* SafeAppsService;\n const result = yield* service.getTransaction(TEST_SAFE_TX_HASH);\n\n expect(Option.isSome(result.txHash)).toBe(true);\n if (Option.isSome(result.txHash)) {\n expect(result.txHash.value).toBe(TEST_TX_HASH);\n }\n }).pipe(Effect.provide(makeMockSafeAppsService({})))\n );\n\n it.effect(\"returns Option.none when not yet executed\", () =>\n Effect.gen(function* () {\n const service = yield* SafeAppsService;\n const result = yield* service.getTransaction(TEST_SAFE_TX_HASH);\n\n expect(Option.isNone(result.txHash)).toBe(true);\n expect(result.status).toBe(\"AWAITING_CONFIRMATIONS\");\n }).pipe(\n Effect.provide(\n makeMockSafeAppsService({\n getTxResult: {\n status: \"AWAITING_CONFIRMATIONS\",\n txHash: Option.none(),\n },\n })\n )\n )\n );\n });\n\n describe(\"waitForTransactionReceipt\", () => {\n it.effect(\"returns SafeTxResult with receipt\", () =>\n Effect.gen(function* () {\n const service = yield* SafeAppsService;\n const result = yield* service.waitForTransactionReceipt(TEST_SAFE_TX_HASH);\n\n expect(result.safeTxHash).toBe(TEST_SAFE_TX_HASH);\n expect(result.onchainHash).toBe(TEST_TX_HASH);\n expect(result.receipt.status).toBe(\"success\");\n expect(result.safeAddress).toBe(TEST_SAFE_ADDRESS);\n expect(result.chainId).toBe(TEST_CHAIN_ID);\n }).pipe(Effect.provide(makeMockSafeAppsService({})))\n );\n });\n\n describe(\"signTypedData\", () => {\n it.effect(\"returns Onchain variant for on-chain signing\", () =>\n Effect.gen(function* () {\n const service = yield* SafeAppsService;\n const result = yield* service.signTypedData({\n domain: { chainId: 1, name: \"Test\" },\n message: { value: \"test\" },\n types: { Test: [{ name: \"value\", type: \"string\" }] },\n });\n\n expect(result._tag).toBe(\"Onchain\");\n if (result._tag === \"Onchain\") {\n expect(result.safeTxHash).toBe(TEST_SAFE_TX_HASH);\n }\n }).pipe(Effect.provide(makeMockSafeAppsService({})))\n );\n\n it.effect(\"returns Offchain variant for off-chain signing\", () =>\n Effect.gen(function* () {\n const service = yield* SafeAppsService;\n const result = yield* service.signTypedData({\n domain: { chainId: 1, name: \"Test\" },\n message: { value: \"test\" },\n types: { Test: [{ name: \"value\", type: \"string\" }] },\n });\n\n expect(result._tag).toBe(\"Offchain\");\n if (result._tag === \"Offchain\") {\n expect(result.messageHash).toBe(TEST_MESSAGE_HASH);\n }\n }).pipe(\n Effect.provide(\n makeMockSafeAppsService({\n signTypedDataResult: {\n _tag: \"Offchain\",\n messageHash: TEST_MESSAGE_HASH,\n },\n })\n )\n )\n );\n });\n\n describe(\"getOffchainSignature\", () => {\n it.effect(\"returns Option.none when signature not yet available\", () =>\n Effect.gen(function* () {\n const service = yield* SafeAppsService;\n const result = yield* service.getOffchainSignature(TEST_MESSAGE_HASH);\n\n expect(Option.isNone(result)).toBe(true);\n }).pipe(Effect.provide(makeMockSafeAppsService({})))\n );\n\n it.effect(\"returns Option.some when signature available\", () =>\n Effect.gen(function* () {\n const service = yield* SafeAppsService;\n const result = yield* service.getOffchainSignature(TEST_MESSAGE_HASH);\n\n expect(Option.isSome(result)).toBe(true);\n if (Option.isSome(result)) {\n expect(result.value).toBe(TEST_SIGNATURE);\n }\n }).pipe(\n Effect.provide(\n makeMockSafeAppsService({\n offchainSignature: Option.some(TEST_SIGNATURE),\n })\n )\n )\n );\n });\n\n describe(\"pollOffchainSignature\", () => {\n it.effect(\"returns signature when available\", () =>\n Effect.gen(function* () {\n const service = yield* SafeAppsService;\n const result = yield* service.pollOffchainSignature(TEST_MESSAGE_HASH);\n\n expect(result.messageHash).toBe(TEST_MESSAGE_HASH);\n expect(result.signature).toBe(TEST_SIGNATURE);\n }).pipe(Effect.provide(makeMockSafeAppsService({})))\n );\n });\n\n describe(\"enableOffchainSigning\", () => {\n it.effect(\"completes without error\", () =>\n Effect.gen(function* () {\n const service = yield* SafeAppsService;\n yield* service.enableOffchainSigning();\n // Success if no error thrown\n }).pipe(Effect.provide(makeMockSafeAppsService({})))\n );\n });\n});\n"]}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
export declare const safeAbis: {
|
|
2
|
-
readonly multiSend: readonly [{
|
|
3
|
-
readonly inputs: readonly [{
|
|
4
|
-
readonly internalType: "bytes";
|
|
5
|
-
readonly name: "transactions";
|
|
6
|
-
readonly type: "bytes";
|
|
7
|
-
}];
|
|
8
|
-
readonly name: "multiSend";
|
|
9
|
-
readonly outputs: readonly [];
|
|
10
|
-
readonly stateMutability: "payable";
|
|
11
|
-
readonly type: "function";
|
|
12
|
-
}];
|
|
13
|
-
readonly multisig: readonly [{
|
|
14
|
-
readonly inputs: readonly [];
|
|
15
|
-
readonly name: "getOwners";
|
|
16
|
-
readonly outputs: readonly [{
|
|
17
|
-
readonly name: "";
|
|
18
|
-
readonly type: "address[]";
|
|
19
|
-
}];
|
|
20
|
-
readonly stateMutability: "view";
|
|
21
|
-
readonly type: "function";
|
|
22
|
-
}, {
|
|
23
|
-
readonly inputs: readonly [{
|
|
24
|
-
readonly internalType: "address";
|
|
25
|
-
readonly name: "targetContract";
|
|
26
|
-
readonly type: "address";
|
|
27
|
-
}, {
|
|
28
|
-
readonly internalType: "bytes";
|
|
29
|
-
readonly name: "calldataPayload";
|
|
30
|
-
readonly type: "bytes";
|
|
31
|
-
}];
|
|
32
|
-
readonly name: "simulateAndRevert";
|
|
33
|
-
readonly outputs: readonly [];
|
|
34
|
-
readonly stateMutability: "nonpayable";
|
|
35
|
-
readonly type: "function";
|
|
36
|
-
}];
|
|
37
|
-
readonly simulateAccessor: readonly [{
|
|
38
|
-
readonly inputs: readonly [{
|
|
39
|
-
readonly internalType: "address";
|
|
40
|
-
readonly name: "to";
|
|
41
|
-
readonly type: "address";
|
|
42
|
-
}, {
|
|
43
|
-
readonly internalType: "uint256";
|
|
44
|
-
readonly name: "value";
|
|
45
|
-
readonly type: "uint256";
|
|
46
|
-
}, {
|
|
47
|
-
readonly internalType: "bytes";
|
|
48
|
-
readonly name: "data";
|
|
49
|
-
readonly type: "bytes";
|
|
50
|
-
}, {
|
|
51
|
-
readonly internalType: "enum Enum.Operation";
|
|
52
|
-
readonly name: "operation";
|
|
53
|
-
readonly type: "uint8";
|
|
54
|
-
}];
|
|
55
|
-
readonly name: "simulate";
|
|
56
|
-
readonly outputs: readonly [{
|
|
57
|
-
readonly internalType: "uint256";
|
|
58
|
-
readonly name: "estimate";
|
|
59
|
-
readonly type: "uint256";
|
|
60
|
-
}, {
|
|
61
|
-
readonly internalType: "bool";
|
|
62
|
-
readonly name: "success";
|
|
63
|
-
readonly type: "bool";
|
|
64
|
-
}, {
|
|
65
|
-
readonly internalType: "bytes";
|
|
66
|
-
readonly name: "returnData";
|
|
67
|
-
readonly type: "bytes";
|
|
68
|
-
}];
|
|
69
|
-
readonly stateMutability: "nonpayable";
|
|
70
|
-
readonly type: "function";
|
|
71
|
-
}];
|
|
72
|
-
};
|
|
73
|
-
//# sourceMappingURL=abis.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"abis.d.ts","sourceRoot":"","sources":["../../../src/safe/simulation/abis.ts"],"names":[],"mappings":"AAkEA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIX,CAAC"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const multisigAbi = [
|
|
2
|
-
{
|
|
3
|
-
inputs: [],
|
|
4
|
-
name: "getOwners",
|
|
5
|
-
outputs: [
|
|
6
|
-
{
|
|
7
|
-
name: "",
|
|
8
|
-
type: "address[]",
|
|
9
|
-
},
|
|
10
|
-
],
|
|
11
|
-
stateMutability: "view",
|
|
12
|
-
type: "function",
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
inputs: [
|
|
16
|
-
{ internalType: "address", name: "targetContract", type: "address" },
|
|
17
|
-
{ internalType: "bytes", name: "calldataPayload", type: "bytes" },
|
|
18
|
-
],
|
|
19
|
-
name: "simulateAndRevert",
|
|
20
|
-
outputs: [],
|
|
21
|
-
stateMutability: "nonpayable",
|
|
22
|
-
type: "function",
|
|
23
|
-
},
|
|
24
|
-
];
|
|
25
|
-
const multiSendAbi = [
|
|
26
|
-
{
|
|
27
|
-
inputs: [{ internalType: "bytes", name: "transactions", type: "bytes" }],
|
|
28
|
-
name: "multiSend",
|
|
29
|
-
outputs: [],
|
|
30
|
-
stateMutability: "payable",
|
|
31
|
-
type: "function",
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
-
const simulateAccessorAbi = [
|
|
35
|
-
{
|
|
36
|
-
inputs: [
|
|
37
|
-
{ internalType: "address", name: "to", type: "address" },
|
|
38
|
-
{ internalType: "uint256", name: "value", type: "uint256" },
|
|
39
|
-
{ internalType: "bytes", name: "data", type: "bytes" },
|
|
40
|
-
{
|
|
41
|
-
internalType: "enum Enum.Operation",
|
|
42
|
-
name: "operation",
|
|
43
|
-
type: "uint8",
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
name: "simulate",
|
|
47
|
-
outputs: [
|
|
48
|
-
{ internalType: "uint256", name: "estimate", type: "uint256" },
|
|
49
|
-
{ internalType: "bool", name: "success", type: "bool" },
|
|
50
|
-
{ internalType: "bytes", name: "returnData", type: "bytes" },
|
|
51
|
-
],
|
|
52
|
-
stateMutability: "nonpayable",
|
|
53
|
-
type: "function",
|
|
54
|
-
},
|
|
55
|
-
];
|
|
56
|
-
export const safeAbis = {
|
|
57
|
-
multiSend: multiSendAbi,
|
|
58
|
-
multisig: multisigAbi,
|
|
59
|
-
simulateAccessor: simulateAccessorAbi,
|
|
60
|
-
};
|
|
61
|
-
//# sourceMappingURL=abis.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"abis.js","sourceRoot":"","sources":["../../../src/safe/simulation/abis.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,GAAG;IAClB;QACE,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,WA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AAE;YACvD,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE;SAC7D;QACD,eAAe,EAAE,YAAY;QAC7B,IAAI,EAAE,UAAU;KACjB;CACO,CAAC;AAEX,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,SAAS,EAAE,YAAY;IACvB,QAAQ,EAAE,WAAW;IACrB,gBAAgB,EAAE,mBAAmB;CAC7B,CAAC","sourcesContent":["/**\n * Safe multisig ABIs for gas simulation and multi-send operations.\n *\n * @see https://github.com/safe-global/safe-deployments\n * @see https://github.com/safe-global/safe-core-sdk/issues/1182\n * @see https://ethereum.stackexchange.com/q/168410/24693\n */\n\nconst multisigAbi = [\n {\n inputs: [],\n name: \"getOwners\",\n outputs: [\n {\n name: \"\",\n type: \"address[]\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"address\", name: \"targetContract\", type: \"address\" },\n { internalType: \"bytes\", name: \"calldataPayload\", type: \"bytes\" },\n ],\n name: \"simulateAndRevert\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n\nconst multiSendAbi = [\n {\n inputs: [{ internalType: \"bytes\", name: \"transactions\", type: \"bytes\" }],\n name: \"multiSend\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\",\n },\n] as const;\n\nconst simulateAccessorAbi = [\n {\n inputs: [\n { internalType: \"address\", name: \"to\", type: \"address\" },\n { internalType: \"uint256\", name: \"value\", type: \"uint256\" },\n { internalType: \"bytes\", name: \"data\", type: \"bytes\" },\n {\n internalType: \"enum Enum.Operation\",\n name: \"operation\",\n type: \"uint8\",\n },\n ],\n name: \"simulate\",\n outputs: [\n { internalType: \"uint256\", name: \"estimate\", type: \"uint256\" },\n { internalType: \"bool\", name: \"success\", type: \"bool\" },\n { internalType: \"bytes\", name: \"returnData\", type: \"bytes\" },\n ],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n\nexport const safeAbis = {\n multiSend: multiSendAbi,\n multisig: multisigAbi,\n simulateAccessor: simulateAccessorAbi,\n} as const;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../../../src/safe/simulation/addresses.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAwEpC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAmBxE;AAOD,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAmB/E"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { abstract, arbitrum, avalanche, base, baseSepolia, berachain, blast, bsc, gnosis, lightlinkPhoenix, linea, mainnet, mode, monad, morph, optimism, polygon, scroll, sei, sepolia, sonic, unichainSepolia, xdc, zksync, } from "viem/chains";
|
|
2
|
-
const SAFE_MULTI_SEND_CHAIN_IDS = [
|
|
3
|
-
abstract.id,
|
|
4
|
-
arbitrum.id,
|
|
5
|
-
avalanche.id,
|
|
6
|
-
base.id,
|
|
7
|
-
baseSepolia.id,
|
|
8
|
-
berachain.id,
|
|
9
|
-
blast.id,
|
|
10
|
-
bsc.id,
|
|
11
|
-
gnosis.id,
|
|
12
|
-
lightlinkPhoenix.id,
|
|
13
|
-
linea.id,
|
|
14
|
-
mainnet.id,
|
|
15
|
-
mode.id,
|
|
16
|
-
monad.id,
|
|
17
|
-
morph.id,
|
|
18
|
-
optimism.id,
|
|
19
|
-
polygon.id,
|
|
20
|
-
scroll.id,
|
|
21
|
-
sei.id,
|
|
22
|
-
sepolia.id,
|
|
23
|
-
sonic.id,
|
|
24
|
-
unichainSepolia.id,
|
|
25
|
-
xdc.id,
|
|
26
|
-
zksync.id,
|
|
27
|
-
];
|
|
28
|
-
const ZK_ROLLUP_CHAIN_IDS = [abstract.id, zksync.id];
|
|
29
|
-
const CUSTOM_DEPLOYMENT_CHAIN_IDS = [lightlinkPhoenix.id, xdc.id];
|
|
30
|
-
export function getMultiSendAddress(chainId) {
|
|
31
|
-
if (!SAFE_MULTI_SEND_CHAIN_IDS.includes(chainId)) {
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
if (ZK_ROLLUP_CHAIN_IDS.includes(chainId)) {
|
|
35
|
-
return "0xf220D3b4DFb23C4ade8C88E526C1353AbAcbC38F";
|
|
36
|
-
}
|
|
37
|
-
if (CUSTOM_DEPLOYMENT_CHAIN_IDS.includes(chainId)) {
|
|
38
|
-
return "0x40A2aCCbd92BCA938b02010E17A5b8929b49130D";
|
|
39
|
-
}
|
|
40
|
-
return "0x9641d764fc13c8B624c04430C7356C1C7C8102e2";
|
|
41
|
-
}
|
|
42
|
-
export function getSimulateAccessorAddress(chainId) {
|
|
43
|
-
if (!SAFE_MULTI_SEND_CHAIN_IDS.includes(chainId)) {
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
if (ZK_ROLLUP_CHAIN_IDS.includes(chainId)) {
|
|
47
|
-
return "0x4191E2e12E8BC5002424CE0c51f9947b02675a44";
|
|
48
|
-
}
|
|
49
|
-
if (CUSTOM_DEPLOYMENT_CHAIN_IDS.includes(chainId)) {
|
|
50
|
-
return "0x59AD6735bCd8152B84860Cb256dD9e96b85F69Da";
|
|
51
|
-
}
|
|
52
|
-
return "0x3d4BA2E0884aa488718476ca2FB8Efc291A46199";
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=addresses.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addresses.js","sourceRoot":"","sources":["../../../src/safe/simulation/addresses.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,WAAW,EACX,SAAS,EACT,KAAK,EACL,GAAG,EACH,MAAM,EACN,gBAAgB,EAChB,KAAK,EACL,OAAO,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AC,EAC7F,CAAC;QACD,OAAO,4CAA4C,CAAC;IACtD,CAAC;IAGD,OAAO,4CAA4C,CAAC;AACtD,CAAC;AAOD,MAAM,UAAU,0BAA0B,CAAC,OAAe;IACxD,IAAI,CAAC,yBAAyB,CAAC,QAAQ,CAAC,OAAqD,CAAC,EAAE,CAAC;QAC/F,OAAO,SAAS,CAAC;IACnB,CAAC;IAGD,IAAI,mBAAmB,CAAC,QAAQ,CAAC,OAA+C,CAAC,EAAE,CAAC;QAClF,OAAO,4CAA4C,CAAC;IACtD,CAAC;IAGD,IACE,2BAA2B,CAAC,QAAQ,CAAC,OAAuD,CAAC,EAC7F,CAAC;QACD,OAAO,4CAA4C,CAAC;IACtD,CAAC;IAGD,OAAO,4CAA4C,CAAC;AACtD,CAAC","sourcesContent":["/**\n * Safe contract addresses for gas simulation and multi-send operations.\n *\n * @see https://github.com/safe-global/safe-deployments/blob/main/src/assets/v1.4.1/multi_send_call_only.json\n * @see https://github.com/safe-global/safe-deployments/blob/main/src/assets/v1.4.1/simulate_tx_accessor.json\n */\nimport type { Address } from \"viem\";\nimport {\n abstract,\n arbitrum,\n avalanche,\n base,\n baseSepolia,\n berachain,\n blast,\n bsc,\n gnosis,\n lightlinkPhoenix,\n linea,\n mainnet,\n mode,\n monad,\n morph,\n optimism,\n polygon,\n scroll,\n sei,\n sepolia,\n sonic,\n unichainSepolia,\n xdc,\n zksync,\n} from \"viem/chains\";\n\n/**\n * Chain IDs for address resolution.\n * These are defined as constants for clarity and maintainability.\n */\n\n/** Chains where Safe MultiSend is available (sourced from old-ui) */\nconst SAFE_MULTI_SEND_CHAIN_IDS = [\n abstract.id,\n arbitrum.id,\n avalanche.id,\n base.id,\n baseSepolia.id,\n berachain.id,\n blast.id,\n bsc.id,\n gnosis.id,\n lightlinkPhoenix.id,\n linea.id,\n mainnet.id,\n mode.id,\n monad.id,\n morph.id,\n optimism.id,\n polygon.id,\n scroll.id,\n sei.id,\n sepolia.id,\n sonic.id,\n unichainSepolia.id,\n xdc.id,\n zksync.id,\n] as const;\n\n/** ZK rollups with custom Safe deployments */\nconst ZK_ROLLUP_CHAIN_IDS = [abstract.id, zksync.id] as const;\n\n/** Chains with custom (non-canonical) Safe deployments */\nconst CUSTOM_DEPLOYMENT_CHAIN_IDS = [lightlinkPhoenix.id, xdc.id] as const;\n\n/**\n * Get the MultiSend contract address for a given chain.\n *\n * Returns undefined for chains where Safe is not deployed.\n */\nexport function getMultiSendAddress(chainId: number): Address | undefined {\n if (!SAFE_MULTI_SEND_CHAIN_IDS.includes(chainId as (typeof SAFE_MULTI_SEND_CHAIN_IDS)[number])) {\n return undefined;\n }\n\n // ZK rollups with custom deployments (Abstract, ZKsync)\n if (ZK_ROLLUP_CHAIN_IDS.includes(chainId as (typeof ZK_ROLLUP_CHAIN_IDS)[number])) {\n return \"0xf220D3b4DFb23C4ade8C88E526C1353AbAcbC38F\";\n }\n\n // Chains with custom deployments (Lightlink, XDC)\n if (\n CUSTOM_DEPLOYMENT_CHAIN_IDS.includes(chainId as (typeof CUSTOM_DEPLOYMENT_CHAIN_IDS)[number])\n ) {\n return \"0x40A2aCCbd92BCA938b02010E17A5b8929b49130D\";\n }\n\n // Canonical deployment for all other chains\n return \"0x9641d764fc13c8B624c04430C7356C1C7C8102e2\";\n}\n\n/**\n * Get the SimulateAccessor contract address for a given chain.\n *\n * Returns undefined for chains where Safe is not deployed.\n */\nexport function getSimulateAccessorAddress(chainId: number): Address | undefined {\n if (!SAFE_MULTI_SEND_CHAIN_IDS.includes(chainId as (typeof SAFE_MULTI_SEND_CHAIN_IDS)[number])) {\n return undefined;\n }\n\n // ZK rollups with custom deployments (Abstract, ZKsync)\n if (ZK_ROLLUP_CHAIN_IDS.includes(chainId as (typeof ZK_ROLLUP_CHAIN_IDS)[number])) {\n return \"0x4191E2e12E8BC5002424CE0c51f9947b02675a44\";\n }\n\n // Chains with custom deployments (Lightlink, XDC)\n if (\n CUSTOM_DEPLOYMENT_CHAIN_IDS.includes(chainId as (typeof CUSTOM_DEPLOYMENT_CHAIN_IDS)[number])\n ) {\n return \"0x59AD6735bCd8152B84860Cb256dD9e96b85F69Da\";\n }\n\n // Canonical deployment for all other chains\n return \"0x3d4BA2E0884aa488718476ca2FB8Efc291A46199\";\n}\n"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Address, Hex } from "viem";
|
|
2
|
-
import type { SafeSimulationTransaction } from "./types.js";
|
|
3
|
-
type InternalTransaction = {
|
|
4
|
-
data: Hex;
|
|
5
|
-
operation: 0 | 1;
|
|
6
|
-
to: Address;
|
|
7
|
-
value: bigint;
|
|
8
|
-
};
|
|
9
|
-
export declare function encodeInternalTransaction(tx: InternalTransaction): string;
|
|
10
|
-
export declare function encodeMultiSend(transactions: SafeSimulationTransaction[]): Hex;
|
|
11
|
-
export declare function decodeSimulationData(revertData: string): {
|
|
12
|
-
gas: bigint;
|
|
13
|
-
success: boolean;
|
|
14
|
-
};
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=encoding.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../../src/safe/simulation/encoding.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAGzC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAG5D,KAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE,GAAG,CAAC;IACV,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC;IACjB,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAoBF,wBAAgB,yBAAyB,CAAC,EAAE,EAAE,mBAAmB,GAAG,MAAM,CAMzE;AAQD,wBAAgB,eAAe,CAAC,YAAY,EAAE,yBAAyB,EAAE,GAAG,GAAG,CAe9E;AAeD,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG;IACxD,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;CAClB,CAyBA"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { decodeAbiParameters, encodeFunctionData, encodePacked } from "viem";
|
|
2
|
-
import { safeAbis } from "./abis.js";
|
|
3
|
-
export function encodeInternalTransaction(tx) {
|
|
4
|
-
const encoded = encodePacked(["uint8", "address", "uint256", "uint256", "bytes"], [tx.operation, tx.to, tx.value, BigInt((tx.data.length - 2) / 2), tx.data]);
|
|
5
|
-
return encoded.slice(2);
|
|
6
|
-
}
|
|
7
|
-
export function encodeMultiSend(transactions) {
|
|
8
|
-
const internals = transactions.map((tx) => ({
|
|
9
|
-
data: tx.data,
|
|
10
|
-
operation: tx.operation ?? 0,
|
|
11
|
-
to: tx.to,
|
|
12
|
-
value: tx.value,
|
|
13
|
-
}));
|
|
14
|
-
const packedData = `0x${internals.map(encodeInternalTransaction).join("")}`;
|
|
15
|
-
return encodeFunctionData({
|
|
16
|
-
abi: safeAbis.multiSend,
|
|
17
|
-
args: [packedData],
|
|
18
|
-
functionName: "multiSend",
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
export function decodeSimulationData(revertData) {
|
|
22
|
-
const minLength = 258;
|
|
23
|
-
if (revertData.length < minLength) {
|
|
24
|
-
throw new Error(`Invalid simulation data: revert data too short. Expected at least ${minLength} characters (${(minLength - 2) / 2} bytes), got ${revertData.length} characters (${Math.max(0, (revertData.length - 2) / 2)} bytes)`);
|
|
25
|
-
}
|
|
26
|
-
const gasAndSuccessData = revertData.slice(2).slice(128, 256);
|
|
27
|
-
const decoded = decodeAbiParameters([
|
|
28
|
-
{ name: "estimate", type: "uint256" },
|
|
29
|
-
{ name: "success", type: "bool" },
|
|
30
|
-
], `0x${gasAndSuccessData}`);
|
|
31
|
-
return {
|
|
32
|
-
gas: decoded[0],
|
|
33
|
-
success: decoded[1],
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|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,CAAC,CAAC;AACL,CAAC;AAeD,MAAM,UAAU,oBAAoB,CAAC,UAAkB;IAOrD,MAAM,SAAS,GAAG,GAAG,CAAC;IACtB,IAAI,UAAU,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,qEAAqE,SAAS,gBAAgB,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,gBAAgB,UAAU,CAAC,MAAM,gBAAgB,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CACpN,CAAC;IACJ,CAAC;IAED,MAAM,iBAAiB,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAE9D,MAAM,OAAO,GAAG,mBAAmB,CACjC;QACE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;QACrC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE;KAClC,EACD,KAAK,iBAAiB,EAAS,CAChC,CAAC;IAEF,OAAO;QACL,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;QACf,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;KACpB,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Encoding utilities for Safe multisig batch transactions.\n *\n * Based on Safe's multiSend encoding scheme and simulation data decoding.\n * @see https://github.com/safe-global/safe-smart-account/blob/c4859f4/contracts/common/StorageAccessible.sol#L32-L43\n * @see https://github.com/safe-global/safe-core-sdk/blob/4f4a0f6/packages/protocol-kit/src/utils/transactions/gas.ts#L353-L358\n */\nimport type { Address, Hex } from \"viem\";\nimport { decodeAbiParameters, encodeFunctionData, encodePacked } from \"viem\";\nimport { safeAbis } from \"./abis.js\";\nimport type { SafeSimulationTransaction } from \"./types.js\";\n\n/** Internal transaction format for Safe multiSend encoding */\ntype InternalTransaction = {\n data: Hex;\n operation: 0 | 1;\n to: Address;\n value: bigint;\n};\n\n/**\n * Encode a single transaction for Safe's multiSend batch execution.\n *\n * Packs transaction data into Safe's internal transaction format using tight encoding:\n * - `operation` (uint8): 0 for CALL, 1 for DELEGATECALL\n * - `to` (address): Target contract address\n * - `value` (uint256): ETH value to send\n * - `dataLength` (uint256): Byte length of calldata\n * - `data` (bytes): ABI-encoded function call\n *\n * The encoding follows Safe's multiSend contract specification where multiple transactions\n * are concatenated into a single bytes payload.\n *\n * @param tx - Transaction to encode\n * @returns Hex-encoded transaction bytes without 0x prefix (for concatenation with other transactions)\n *\n * @see https://github.com/safe-global/safe-smart-account/blob/c4859f4/contracts/common/StorageAccessible.sol#L32-L43\n */\nexport function encodeInternalTransaction(tx: InternalTransaction): string {\n const encoded = encodePacked(\n [\"uint8\", \"address\", \"uint256\", \"uint256\", \"bytes\"],\n [tx.operation, tx.to, tx.value, BigInt((tx.data.length - 2) / 2), tx.data]\n );\n return encoded.slice(2); // Remove 0x prefix for concatenation\n}\n\n/**\n * Encode multiple transactions for Safe multiSend.\n *\n * @param transactions - Array of transactions to encode\n * @returns Encoded calldata for multiSend function\n */\nexport function encodeMultiSend(transactions: SafeSimulationTransaction[]): Hex {\n const internals = transactions.map((tx) => ({\n data: tx.data,\n operation: tx.operation ?? 0,\n to: tx.to,\n value: tx.value,\n }));\n\n const packedData = `0x${internals.map(encodeInternalTransaction).join(\"\")}` as Hex;\n\n return encodeFunctionData({\n abi: safeAbis.multiSend,\n args: [packedData],\n functionName: \"multiSend\",\n });\n}\n\n/**\n * Decode simulation revert data to extract gas estimate and success flag.\n *\n * Safe uses a custom encoding scheme for the revert data. The gas limit is the 3rd EVM word,\n * and success is the 4th one. Each word is 64 hex chars (32 bytes).\n *\n * IMPORTANT: This function may throw an error when the revert data is not due to a legitimate\n * response from `simulateAndRevert`.\n *\n * @param revertData - The revert data from simulateAndRevert call\n * @returns Gas estimate and success flag\n * @throws Error if revert data is too short to contain valid gas and success data\n */\nexport function decodeSimulationData(revertData: string): {\n gas: bigint;\n success: boolean;\n} {\n // Gas estimate is at EVM word 3, success at word 4\n // Each word is 64 hex chars (32 bytes)\n // Total required: 0x prefix (2) + 128 chars (4 words) + 128 chars (2 words for gas and success) = 258 chars\n const minLength = 258;\n if (revertData.length < minLength) {\n throw new Error(\n `Invalid simulation data: revert data too short. Expected at least ${minLength} characters (${(minLength - 2) / 2} bytes), got ${revertData.length} characters (${Math.max(0, (revertData.length - 2) / 2)} bytes)`\n );\n }\n\n const gasAndSuccessData = revertData.slice(2).slice(128, 256);\n\n const decoded = decodeAbiParameters(\n [\n { name: \"estimate\", type: \"uint256\" },\n { name: \"success\", type: \"bool\" },\n ],\n `0x${gasAndSuccessData}` as Hex\n );\n\n return {\n gas: decoded[0],\n success: decoded[1],\n };\n}\n"]}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
declare const GasLimitOverflowError_base: Schema.TaggedErrorClass<GasLimitOverflowError, "GasLimitOverflowError", {
|
|
3
|
-
readonly _tag: Schema.tag<"GasLimitOverflowError">;
|
|
4
|
-
} & {
|
|
5
|
-
blockGasLimit: typeof Schema.BigInt;
|
|
6
|
-
estimatedGas: typeof Schema.BigInt;
|
|
7
|
-
message: typeof Schema.String;
|
|
8
|
-
threshold: typeof Schema.BigInt;
|
|
9
|
-
}>;
|
|
10
|
-
export declare class GasLimitOverflowError extends GasLimitOverflowError_base {
|
|
11
|
-
}
|
|
12
|
-
declare const SafeSimulationFailedError_base: Schema.TaggedErrorClass<SafeSimulationFailedError, "SafeSimulationFailedError", {
|
|
13
|
-
readonly _tag: Schema.tag<"SafeSimulationFailedError">;
|
|
14
|
-
} & {
|
|
15
|
-
cause: Schema.optional<typeof Schema.Unknown>;
|
|
16
|
-
message: typeof Schema.String;
|
|
17
|
-
}>;
|
|
18
|
-
export declare class SafeSimulationFailedError extends SafeSimulationFailedError_base {
|
|
19
|
-
}
|
|
20
|
-
declare const SafeContractsNotDeployedError_base: Schema.TaggedErrorClass<SafeContractsNotDeployedError, "SafeContractsNotDeployedError", {
|
|
21
|
-
readonly _tag: Schema.tag<"SafeContractsNotDeployedError">;
|
|
22
|
-
} & {
|
|
23
|
-
chainId: typeof Schema.Number;
|
|
24
|
-
message: typeof Schema.String;
|
|
25
|
-
missingContract: Schema.Literal<["multiSend", "simulateAccessor"]>;
|
|
26
|
-
}>;
|
|
27
|
-
export declare class SafeContractsNotDeployedError extends SafeContractsNotDeployedError_base {
|
|
28
|
-
}
|
|
29
|
-
declare const TransactionSizeTooLargeError_base: Schema.TaggedErrorClass<TransactionSizeTooLargeError, "TransactionSizeTooLargeError", {
|
|
30
|
-
readonly _tag: Schema.tag<"TransactionSizeTooLargeError">;
|
|
31
|
-
} & {
|
|
32
|
-
actualSize: typeof Schema.Number;
|
|
33
|
-
maxSize: typeof Schema.Number;
|
|
34
|
-
message: typeof Schema.String;
|
|
35
|
-
}>;
|
|
36
|
-
export declare class TransactionSizeTooLargeError extends TransactionSizeTooLargeError_base {
|
|
37
|
-
}
|
|
38
|
-
declare const SimulationDecodeError_base: Schema.TaggedErrorClass<SimulationDecodeError, "SimulationDecodeError", {
|
|
39
|
-
readonly _tag: Schema.tag<"SimulationDecodeError">;
|
|
40
|
-
} & {
|
|
41
|
-
cause: typeof Schema.Unknown;
|
|
42
|
-
message: typeof Schema.String;
|
|
43
|
-
revertData: typeof Schema.String;
|
|
44
|
-
}>;
|
|
45
|
-
export declare class SimulationDecodeError extends SimulationDecodeError_base {
|
|
46
|
-
}
|
|
47
|
-
declare const InvalidGasThresholdError_base: Schema.TaggedErrorClass<InvalidGasThresholdError, "InvalidGasThresholdError", {
|
|
48
|
-
readonly _tag: Schema.tag<"InvalidGasThresholdError">;
|
|
49
|
-
} & {
|
|
50
|
-
message: typeof Schema.String;
|
|
51
|
-
value: typeof Schema.Number;
|
|
52
|
-
}>;
|
|
53
|
-
export declare class InvalidGasThresholdError extends InvalidGasThresholdError_base {
|
|
54
|
-
}
|
|
55
|
-
export {};
|
|
56
|
-
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/safe/simulation/errors.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;;;;;AAGhC,qBAAa,qBAAsB,SAAQ,0BAQ1C;CAAG;;;;;;;AAGJ,qBAAa,yBAA0B,SAAQ,8BAM9C;CAAG;;;;;;;;AAGJ,qBAAa,6BAA8B,SAAQ,kCAOlD;CAAG;;;;;;;;AAGJ,qBAAa,4BAA6B,SAAQ,iCAOjD;CAAG;;;;;;;;AAGJ,qBAAa,qBAAsB,SAAQ,0BAO1C;CAAG;;;;;;;AAGJ,qBAAa,wBAAyB,SAAQ,6BAM7C;CAAG"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
export class GasLimitOverflowError extends Schema.TaggedError()("GasLimitOverflowError", {
|
|
3
|
-
blockGasLimit: Schema.BigInt,
|
|
4
|
-
estimatedGas: Schema.BigInt,
|
|
5
|
-
message: Schema.String,
|
|
6
|
-
threshold: Schema.BigInt,
|
|
7
|
-
}) {
|
|
8
|
-
}
|
|
9
|
-
export class SafeSimulationFailedError extends Schema.TaggedError()("SafeSimulationFailedError", {
|
|
10
|
-
cause: Schema.optional(Schema.Unknown),
|
|
11
|
-
message: Schema.String,
|
|
12
|
-
}) {
|
|
13
|
-
}
|
|
14
|
-
export class SafeContractsNotDeployedError extends Schema.TaggedError()("SafeContractsNotDeployedError", {
|
|
15
|
-
chainId: Schema.Number,
|
|
16
|
-
message: Schema.String,
|
|
17
|
-
missingContract: Schema.Literal("multiSend", "simulateAccessor"),
|
|
18
|
-
}) {
|
|
19
|
-
}
|
|
20
|
-
export class TransactionSizeTooLargeError extends Schema.TaggedError()("TransactionSizeTooLargeError", {
|
|
21
|
-
actualSize: Schema.Number,
|
|
22
|
-
maxSize: Schema.Number,
|
|
23
|
-
message: Schema.String,
|
|
24
|
-
}) {
|
|
25
|
-
}
|
|
26
|
-
export class SimulationDecodeError extends Schema.TaggedError()("SimulationDecodeError", {
|
|
27
|
-
cause: Schema.Unknown,
|
|
28
|
-
message: Schema.String,
|
|
29
|
-
revertData: Schema.String,
|
|
30
|
-
}) {
|
|
31
|
-
}
|
|
32
|
-
export class InvalidGasThresholdError extends Schema.TaggedError()("InvalidGasThresholdError", {
|
|
33
|
-
message: Schema.String,
|
|
34
|
-
value: Schema.Number,
|
|
35
|
-
}) {
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/safe/simulation/errors.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,MAAM,OAAO,qBAAsB,SAAQ,MAAM,CAAC,WAAW,EAAyB,CACpF,uBAAuB,EACvB;IACE,aAAa,EAAE,MAAM,CAAC,MAAM;IAC5B,YAAY,EAAE,MAAM,CAAC,MAAM;IAC3B,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,SAAS,EAAE,MAAM,CAAC,MAAM;CACzB,CACF;CAAG;AAGJ,MAAM,OAAO,yBAA0B,SAAQ,MAAM,CAAC,WAAW,EAA6B,CAC5F,2BAA2B,EAC3B;IACE,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CACF;CAAG;AAGJ,MAAM,OAAO,6BAA8B,SAAQ,MAAM,CAAC,WAAW,EAAiC,CACpG,+BAA+B,EAC/B;IACE,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,eAAe,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,kBAAkB,CAAC;CACjE,CACF;CAAG;AAGJ,MAAM,OAAO,4BAA6B,SAAQ,MAAM,CAAC,WAAW,EAAgC,CAClG,8BAA8B,EAC9B;IACE,UAAU,EAAE,MAAM,CAAC,MAAM;IACzB,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CACF;CAAG;AAGJ,MAAM,OAAO,qBAAsB,SAAQ,MAAM,CAAC,WAAW,EAAyB,CACpF,uBAAuB,EACvB;IACE,KAAK,EAAE,MAAM,CAAC,OAAO;IACrB,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,UAAU,EAAE,MAAM,CAAC,MAAM;CAC1B,CACF;CAAG;AAGJ,MAAM,OAAO,wBAAyB,SAAQ,MAAM,CAAC,WAAW,EAA4B,CAC1F,0BAA0B,EAC1B;IACE,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,KAAK,EAAE,MAAM,CAAC,MAAM;CACrB,CACF;CAAG","sourcesContent":["/**\n * Tagged errors for Safe multisig gas simulation operations.\n *\n * These errors use Effect-TS Schema.TaggedError pattern for type-safe error handling.\n */\nimport { Schema } from \"effect\";\n\n/** Gas consumption exceeds block gas limit threshold */\nexport class GasLimitOverflowError extends Schema.TaggedError<GasLimitOverflowError>()(\n \"GasLimitOverflowError\",\n {\n blockGasLimit: Schema.BigInt,\n estimatedGas: Schema.BigInt,\n message: Schema.String,\n threshold: Schema.BigInt,\n }\n) {}\n\n/** Safe simulation failed */\nexport class SafeSimulationFailedError extends Schema.TaggedError<SafeSimulationFailedError>()(\n \"SafeSimulationFailedError\",\n {\n cause: Schema.optional(Schema.Unknown),\n message: Schema.String,\n }\n) {}\n\n/** Safe contracts not deployed on this chain */\nexport class SafeContractsNotDeployedError extends Schema.TaggedError<SafeContractsNotDeployedError>()(\n \"SafeContractsNotDeployedError\",\n {\n chainId: Schema.Number,\n message: Schema.String,\n missingContract: Schema.Literal(\"multiSend\", \"simulateAccessor\"),\n }\n) {}\n\n/** Transaction size too large */\nexport class TransactionSizeTooLargeError extends Schema.TaggedError<TransactionSizeTooLargeError>()(\n \"TransactionSizeTooLargeError\",\n {\n actualSize: Schema.Number,\n maxSize: Schema.Number,\n message: Schema.String,\n }\n) {}\n\n/** Simulation revert data decode failed */\nexport class SimulationDecodeError extends Schema.TaggedError<SimulationDecodeError>()(\n \"SimulationDecodeError\",\n {\n cause: Schema.Unknown,\n message: Schema.String,\n revertData: Schema.String,\n }\n) {}\n\n/** Invalid gas threshold percent */\nexport class InvalidGasThresholdError extends Schema.TaggedError<InvalidGasThresholdError>()(\n \"InvalidGasThresholdError\",\n {\n message: Schema.String,\n value: Schema.Number,\n }\n) {}\n"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { safeAbis } from "./abis.js";
|
|
2
|
-
export { getMultiSendAddress, getSimulateAccessorAddress, } from "./addresses.js";
|
|
3
|
-
export { decodeSimulationData, encodeMultiSend } from "./encoding.js";
|
|
4
|
-
export { GasLimitOverflowError, InvalidGasThresholdError, SafeContractsNotDeployedError, SafeSimulationFailedError, SimulationDecodeError, TransactionSizeTooLargeError, } from "./errors.js";
|
|
5
|
-
export { SafeSimulationService, SafeSimulationServiceLive, type SafeSimulationServiceShape, } from "./service.js";
|
|
6
|
-
export type { SafeOperation, SafeSimulateBatchParams, SafeSimulationResult, SafeSimulationTransaction, } from "./types.js";
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/safe/simulation/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EACL,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,6BAA6B,EAC7B,yBAAyB,EACzB,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,KAAK,0BAA0B,GAChC,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,aAAa,EACb,uBAAuB,EACvB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,YAAY,CAAC"}
|