@rabby-wallet/gnosis-sdk 1.3.9 → 1.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +78 -0
- package/dist/api.js +17 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.js +19 -13
- package/package.json +5 -5
- package/src/api.ts +18 -1
- package/src/index.ts +34 -49
package/dist/api.d.ts
CHANGED
|
@@ -41,6 +41,84 @@ export interface SafeTransactionItem {
|
|
|
41
41
|
confirmations: ConfirmationItem[];
|
|
42
42
|
signatures: string | null;
|
|
43
43
|
}
|
|
44
|
+
export declare const HOST_MAP: {
|
|
45
|
+
/**
|
|
46
|
+
* eth
|
|
47
|
+
*/
|
|
48
|
+
"1": string;
|
|
49
|
+
/**
|
|
50
|
+
* polygon
|
|
51
|
+
*/
|
|
52
|
+
"137": string;
|
|
53
|
+
/**
|
|
54
|
+
* bsc
|
|
55
|
+
*/
|
|
56
|
+
"56": string;
|
|
57
|
+
/**
|
|
58
|
+
* Gnosis Chain
|
|
59
|
+
*/
|
|
60
|
+
"100": string;
|
|
61
|
+
/**
|
|
62
|
+
* avalanche
|
|
63
|
+
*/
|
|
64
|
+
"43114": string;
|
|
65
|
+
/**
|
|
66
|
+
* arbitrum
|
|
67
|
+
*/
|
|
68
|
+
"42161": string;
|
|
69
|
+
/**
|
|
70
|
+
* Optimism
|
|
71
|
+
*/
|
|
72
|
+
"10": string;
|
|
73
|
+
/**
|
|
74
|
+
* Aurora
|
|
75
|
+
*/
|
|
76
|
+
"1313161554": string;
|
|
77
|
+
/**
|
|
78
|
+
* Base
|
|
79
|
+
*/
|
|
80
|
+
"8453": string;
|
|
81
|
+
/**
|
|
82
|
+
* Celo
|
|
83
|
+
*/
|
|
84
|
+
"42220": string;
|
|
85
|
+
/**
|
|
86
|
+
* Polygon zkEVM
|
|
87
|
+
*/
|
|
88
|
+
"1101": string;
|
|
89
|
+
/**
|
|
90
|
+
* zksync era
|
|
91
|
+
*/
|
|
92
|
+
"324": string;
|
|
93
|
+
/**
|
|
94
|
+
* scroll
|
|
95
|
+
*/
|
|
96
|
+
"534352": string;
|
|
97
|
+
/**
|
|
98
|
+
* linea
|
|
99
|
+
*/
|
|
100
|
+
"59144": string;
|
|
101
|
+
/**
|
|
102
|
+
* X Layer
|
|
103
|
+
*/
|
|
104
|
+
"196": string;
|
|
105
|
+
/**
|
|
106
|
+
* mantle
|
|
107
|
+
*/
|
|
108
|
+
"5000": string;
|
|
109
|
+
/**
|
|
110
|
+
* World Chain
|
|
111
|
+
*/
|
|
112
|
+
"480": string;
|
|
113
|
+
/**
|
|
114
|
+
* blast
|
|
115
|
+
*/
|
|
116
|
+
"81457": string;
|
|
117
|
+
/**
|
|
118
|
+
* Sonic
|
|
119
|
+
*/
|
|
120
|
+
"146": string;
|
|
121
|
+
};
|
|
44
122
|
export default class RequestProvider {
|
|
45
123
|
host: string;
|
|
46
124
|
request: Axios;
|
package/dist/api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isLegacyVersion } from "./utils";
|
|
2
2
|
import axios from "axios";
|
|
3
3
|
import { toChecksumAddress } from "web3-utils";
|
|
4
|
-
const HOST_MAP = {
|
|
4
|
+
export const HOST_MAP = {
|
|
5
5
|
/**
|
|
6
6
|
* eth
|
|
7
7
|
*/
|
|
@@ -62,6 +62,22 @@ const HOST_MAP = {
|
|
|
62
62
|
* X Layer
|
|
63
63
|
*/
|
|
64
64
|
"196": "https://safe-transaction-xlayer.safe.global/api/v1",
|
|
65
|
+
/**
|
|
66
|
+
* mantle
|
|
67
|
+
*/
|
|
68
|
+
"5000": "https://safe-transaction-mantle.safe.global/api/v1",
|
|
69
|
+
/**
|
|
70
|
+
* World Chain
|
|
71
|
+
*/
|
|
72
|
+
"480": "https://safe-transaction-worldchain.safe.global/api/v1",
|
|
73
|
+
/**
|
|
74
|
+
* blast
|
|
75
|
+
*/
|
|
76
|
+
"81457": "https://safe-transaction-blast.safe.global/api/v1",
|
|
77
|
+
/**
|
|
78
|
+
* Sonic
|
|
79
|
+
*/
|
|
80
|
+
"146": "https://safe-transaction-sonic.safe.global/api/v1",
|
|
65
81
|
};
|
|
66
82
|
export default class RequestProvider {
|
|
67
83
|
constructor(networkId, adapter) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { Contract } from "ethers";
|
|
2
1
|
import { BigNumber } from "@ethersproject/bignumber";
|
|
3
|
-
import {
|
|
4
|
-
import { SafeTransactionDataPartial, SafeSignature } from "@gnosis.pm/safe-core-sdk-types";
|
|
5
|
-
import { TransactionResult, TransactionOptions } from "@gnosis.pm/safe-core-sdk/dist/src/utils/transactions/types";
|
|
2
|
+
import { SafeSignature, SafeTransactionDataPartial } from "@gnosis.pm/safe-core-sdk-types";
|
|
6
3
|
import SafeTransaction from "@gnosis.pm/safe-core-sdk/dist/src/utils/transactions/SafeTransaction";
|
|
4
|
+
import { TransactionOptions, TransactionResult } from "@gnosis.pm/safe-core-sdk/dist/src/utils/transactions/types";
|
|
5
|
+
import SafeApiKit, { SafeMessage as ApiKitSafeMessage } from "@safe-global/api-kit";
|
|
7
6
|
import SafeMessage from "@safe-global/protocol-kit/dist/src/utils/messages/SafeMessage";
|
|
8
|
-
import RequestProvider, { SafeInfo } from "./api";
|
|
9
|
-
import { AxiosAdapter } from "axios";
|
|
10
|
-
import SafeApiKit from "@safe-global/api-kit";
|
|
11
7
|
import { SafeClientResult } from "@safe-global/sdk-starter-kit";
|
|
8
|
+
import { AxiosAdapter } from "axios";
|
|
9
|
+
import { Contract, providers } from "ethers";
|
|
10
|
+
import RequestProvider, { SafeInfo } from "./api";
|
|
12
11
|
declare class Safe {
|
|
13
12
|
contract: Contract;
|
|
14
13
|
safeAddress: string;
|
|
@@ -31,6 +30,7 @@ declare class Safe {
|
|
|
31
30
|
static getPendingTransactions(safeAddress: string, network: string, nonce: number): Promise<{
|
|
32
31
|
results: import("./api").SafeTransactionItem[];
|
|
33
32
|
}>;
|
|
33
|
+
static createSafeApiKit: (network: string) => SafeApiKit;
|
|
34
34
|
getPendingTransactions(): Promise<{
|
|
35
35
|
results: import("./api").SafeTransactionItem[];
|
|
36
36
|
}>;
|
|
@@ -80,3 +80,4 @@ declare class Safe {
|
|
|
80
80
|
}
|
|
81
81
|
export default Safe;
|
|
82
82
|
export type BasicSafeInfo = Awaited<ReturnType<Safe["getBasicSafeInfo"]>>;
|
|
83
|
+
export { ApiKitSafeMessage as SafeMessage };
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { Contract } from "ethers";
|
|
2
1
|
import { BigNumber } from "@ethersproject/bignumber";
|
|
3
|
-
import BN from "bignumber.js";
|
|
4
|
-
import { getSafeSingletonDeployment } from "@safe-global/safe-deployments";
|
|
5
|
-
import { toChecksumAddress } from "web3-utils";
|
|
6
2
|
import SafeTransaction from "@gnosis.pm/safe-core-sdk/dist/src/utils/transactions/SafeTransaction";
|
|
7
|
-
import { hashSafeMessage, } from "@safe-global/protocol-kit";
|
|
8
|
-
import RequestProvider from "./api";
|
|
9
|
-
import { standardizeSafeTransactionData, sameString, generateSignature, generatePreValidatedSignature, estimateGasForTransactionExecution, } from "./utils";
|
|
10
|
-
import { calculateSafeMessageHash, } from "@safe-global/protocol-kit/dist/src/utils";
|
|
11
3
|
import SafeApiKit from "@safe-global/api-kit";
|
|
4
|
+
import { TRANSACTION_SERVICE_URLS } from "@safe-global/api-kit/dist/src/utils/config";
|
|
5
|
+
import { hashSafeMessage } from "@safe-global/protocol-kit";
|
|
6
|
+
import { calculateSafeMessageHash } from "@safe-global/protocol-kit/dist/src/utils";
|
|
7
|
+
import { getSafeSingletonDeployment } from "@safe-global/safe-deployments";
|
|
12
8
|
import { SafeClientTxStatus } from "@safe-global/sdk-starter-kit/dist/src/constants";
|
|
13
9
|
import { createSafeClientResult } from "@safe-global/sdk-starter-kit/dist/src/utils";
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
import BN from "bignumber.js";
|
|
11
|
+
import { Contract } from "ethers";
|
|
12
|
+
import { toChecksumAddress } from "web3-utils";
|
|
13
|
+
import RequestProvider, { HOST_MAP } from "./api";
|
|
14
|
+
import { estimateGasForTransactionExecution, generatePreValidatedSignature, generateSignature, sameString, standardizeSafeTransactionData, } from "./utils";
|
|
16
15
|
class Safe {
|
|
17
16
|
constructor(safeAddress, version, provider, network = "1") {
|
|
18
17
|
this.owners = [];
|
|
@@ -60,9 +59,7 @@ class Safe {
|
|
|
60
59
|
this.safeAddress = safeAddress;
|
|
61
60
|
this.network = network;
|
|
62
61
|
this.request = new RequestProvider(network, Safe.adapter);
|
|
63
|
-
this.apiKit =
|
|
64
|
-
chainId: BigInt(network),
|
|
65
|
-
});
|
|
62
|
+
this.apiKit = Safe.createSafeApiKit(network);
|
|
66
63
|
// this.init();
|
|
67
64
|
}
|
|
68
65
|
/**
|
|
@@ -261,4 +258,13 @@ class Safe {
|
|
|
261
258
|
});
|
|
262
259
|
}
|
|
263
260
|
}
|
|
261
|
+
Safe.createSafeApiKit = (network) => {
|
|
262
|
+
var _a;
|
|
263
|
+
return new SafeApiKit({
|
|
264
|
+
chainId: BigInt(network),
|
|
265
|
+
txServiceUrl: TRANSACTION_SERVICE_URLS[network] ||
|
|
266
|
+
((_a = HOST_MAP[network]) === null || _a === void 0 ? void 0 : _a.replace(/\/v1$/, "")) ||
|
|
267
|
+
undefined,
|
|
268
|
+
});
|
|
269
|
+
};
|
|
264
270
|
export default Safe;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rabby-wallet/gnosis-sdk",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
"@ethersproject/solidity": "5.5.0",
|
|
17
17
|
"@gnosis.pm/safe-core-sdk": "1.0.0",
|
|
18
18
|
"@gnosis.pm/safe-core-sdk-types": "0.1.1",
|
|
19
|
-
"@safe-global/api-kit": "2.5.
|
|
19
|
+
"@safe-global/api-kit": "2.5.6",
|
|
20
20
|
"@safe-global/protocol-kit": "5.0.2",
|
|
21
|
-
"@safe-global/safe-deployments": "1.37.
|
|
22
|
-
"@safe-global/sdk-starter-kit": "1.
|
|
23
|
-
"@safe-global/types-kit": "1.0.
|
|
21
|
+
"@safe-global/safe-deployments": "1.37.22",
|
|
22
|
+
"@safe-global/sdk-starter-kit": "1.1.1",
|
|
23
|
+
"@safe-global/types-kit": "1.0.1",
|
|
24
24
|
"axios": "0.24.0",
|
|
25
25
|
"bignumber.js": "9.0.2",
|
|
26
26
|
"ethereumjs-util": "7.1.3",
|
package/src/api.ts
CHANGED
|
@@ -47,7 +47,7 @@ export interface SafeTransactionItem {
|
|
|
47
47
|
signatures: string | null;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
const HOST_MAP = {
|
|
50
|
+
export const HOST_MAP = {
|
|
51
51
|
/**
|
|
52
52
|
* eth
|
|
53
53
|
*/
|
|
@@ -108,6 +108,23 @@ const HOST_MAP = {
|
|
|
108
108
|
* X Layer
|
|
109
109
|
*/
|
|
110
110
|
"196": "https://safe-transaction-xlayer.safe.global/api/v1",
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* mantle
|
|
114
|
+
*/
|
|
115
|
+
"5000": "https://safe-transaction-mantle.safe.global/api/v1",
|
|
116
|
+
/**
|
|
117
|
+
* World Chain
|
|
118
|
+
*/
|
|
119
|
+
"480": "https://safe-transaction-worldchain.safe.global/api/v1",
|
|
120
|
+
/**
|
|
121
|
+
* blast
|
|
122
|
+
*/
|
|
123
|
+
"81457": "https://safe-transaction-blast.safe.global/api/v1",
|
|
124
|
+
/**
|
|
125
|
+
* Sonic
|
|
126
|
+
*/
|
|
127
|
+
"146": "https://safe-transaction-sonic.safe.global/api/v1",
|
|
111
128
|
};
|
|
112
129
|
|
|
113
130
|
export default class RequestProvider {
|
package/src/index.ts
CHANGED
|
@@ -1,62 +1,37 @@
|
|
|
1
|
-
import { Contract, ethers } from "ethers";
|
|
2
1
|
import { BigNumber } from "@ethersproject/bignumber";
|
|
3
|
-
import BN from "bignumber.js";
|
|
4
|
-
import { getSafeSingletonDeployment } from "@safe-global/safe-deployments";
|
|
5
|
-
import { providers } from "ethers";
|
|
6
|
-
import { toChecksumAddress } from "web3-utils";
|
|
7
2
|
import {
|
|
8
|
-
SafeTransactionDataPartial,
|
|
9
3
|
SafeSignature,
|
|
4
|
+
SafeTransactionDataPartial,
|
|
10
5
|
} from "@gnosis.pm/safe-core-sdk-types";
|
|
6
|
+
import SafeTransaction from "@gnosis.pm/safe-core-sdk/dist/src/utils/transactions/SafeTransaction";
|
|
11
7
|
import {
|
|
12
|
-
TransactionResult,
|
|
13
8
|
TransactionOptions,
|
|
9
|
+
TransactionResult,
|
|
14
10
|
} from "@gnosis.pm/safe-core-sdk/dist/src/utils/transactions/types";
|
|
15
|
-
import SafeTransaction from "@gnosis.pm/safe-core-sdk/dist/src/utils/transactions/SafeTransaction";
|
|
16
|
-
import SafeTransactionNew from "@safe-global/protocol-kit/dist/src/utils/transactions/SafeTransaction";
|
|
17
|
-
import SafeMessage from "@safe-global/protocol-kit/dist/src/utils/messages/SafeMessage";
|
|
18
|
-
import SafeProtocolKit, {
|
|
19
|
-
generateEIP712Signature,
|
|
20
|
-
hashSafeMessage,
|
|
21
|
-
preimageSafeMessageHash,
|
|
22
|
-
SafeProvider,
|
|
23
|
-
SigningMethod,
|
|
24
|
-
SigningMethodType,
|
|
25
|
-
} from "@safe-global/protocol-kit";
|
|
26
|
-
import RequestProvider, { SafeInfo } from "./api";
|
|
27
|
-
import {
|
|
28
|
-
standardizeSafeTransactionData,
|
|
29
|
-
sameString,
|
|
30
|
-
generateSignature,
|
|
31
|
-
generatePreValidatedSignature,
|
|
32
|
-
estimateGasForTransactionExecution,
|
|
33
|
-
} from "./utils";
|
|
34
|
-
import { AxiosAdapter } from "axios";
|
|
35
|
-
import semverSatisfies from "semver/functions/satisfies";
|
|
36
|
-
import {
|
|
37
|
-
EIP712TypedData,
|
|
38
|
-
SafeEIP712Args,
|
|
39
|
-
SafeSignature as SafeSignatureNew,
|
|
40
|
-
} from "@safe-global/types-kit";
|
|
41
|
-
import {
|
|
42
|
-
calculateSafeMessageHash,
|
|
43
|
-
EthSafeSignature,
|
|
44
|
-
generateSignature as generateSignatureNew,
|
|
45
|
-
hasSafeFeature,
|
|
46
|
-
SAFE_FEATURES,
|
|
47
|
-
} from "@safe-global/protocol-kit/dist/src/utils";
|
|
48
11
|
import SafeApiKit, {
|
|
49
12
|
EIP712TypedData as ApiKitEIP712TypedData,
|
|
13
|
+
SafeMessage as ApiKitSafeMessage,
|
|
50
14
|
} from "@safe-global/api-kit";
|
|
15
|
+
import { TRANSACTION_SERVICE_URLS } from "@safe-global/api-kit/dist/src/utils/config";
|
|
16
|
+
import { hashSafeMessage } from "@safe-global/protocol-kit";
|
|
17
|
+
import { calculateSafeMessageHash } from "@safe-global/protocol-kit/dist/src/utils";
|
|
18
|
+
import SafeMessage from "@safe-global/protocol-kit/dist/src/utils/messages/SafeMessage";
|
|
19
|
+
import { getSafeSingletonDeployment } from "@safe-global/safe-deployments";
|
|
20
|
+
import { SafeClientResult } from "@safe-global/sdk-starter-kit";
|
|
51
21
|
import { SafeClientTxStatus } from "@safe-global/sdk-starter-kit/dist/src/constants";
|
|
52
22
|
import { createSafeClientResult } from "@safe-global/sdk-starter-kit/dist/src/utils";
|
|
23
|
+
import { AxiosAdapter } from "axios";
|
|
24
|
+
import BN from "bignumber.js";
|
|
25
|
+
import { Contract, providers } from "ethers";
|
|
26
|
+
import { toChecksumAddress } from "web3-utils";
|
|
27
|
+
import RequestProvider, { HOST_MAP, SafeInfo } from "./api";
|
|
53
28
|
import {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
29
|
+
estimateGasForTransactionExecution,
|
|
30
|
+
generatePreValidatedSignature,
|
|
31
|
+
generateSignature,
|
|
32
|
+
sameString,
|
|
33
|
+
standardizeSafeTransactionData,
|
|
34
|
+
} from "./utils";
|
|
60
35
|
|
|
61
36
|
class Safe {
|
|
62
37
|
contract: Contract;
|
|
@@ -90,9 +65,7 @@ class Safe {
|
|
|
90
65
|
this.safeAddress = safeAddress;
|
|
91
66
|
this.network = network;
|
|
92
67
|
this.request = new RequestProvider(network, Safe.adapter);
|
|
93
|
-
this.apiKit =
|
|
94
|
-
chainId: BigInt(network),
|
|
95
|
-
});
|
|
68
|
+
this.apiKit = Safe.createSafeApiKit(network);
|
|
96
69
|
|
|
97
70
|
// this.init();
|
|
98
71
|
}
|
|
@@ -122,6 +95,16 @@ class Safe {
|
|
|
122
95
|
return transactions;
|
|
123
96
|
}
|
|
124
97
|
|
|
98
|
+
static createSafeApiKit = (network: string) => {
|
|
99
|
+
return new SafeApiKit({
|
|
100
|
+
chainId: BigInt(network),
|
|
101
|
+
txServiceUrl:
|
|
102
|
+
TRANSACTION_SERVICE_URLS[network] ||
|
|
103
|
+
HOST_MAP[network]?.replace(/\/v1$/, "") ||
|
|
104
|
+
undefined,
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
|
|
125
108
|
async getPendingTransactions() {
|
|
126
109
|
const nonce = await this.getNonce();
|
|
127
110
|
const transactions = await this.request.getPendingTransactions(
|
|
@@ -439,3 +422,5 @@ class Safe {
|
|
|
439
422
|
export default Safe;
|
|
440
423
|
|
|
441
424
|
export type BasicSafeInfo = Awaited<ReturnType<Safe["getBasicSafeInfo"]>>;
|
|
425
|
+
|
|
426
|
+
export { ApiKitSafeMessage as SafeMessage };
|