@rabby-wallet/gnosis-sdk 1.0.1 → 1.2.0
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.js +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +11 -9
- package/dist/utils.d.ts +0 -3
- package/dist/utils.js +0 -5
- package/package.json +2 -1
- package/src/api.ts +2 -2
- package/src/index.ts +16 -12
- package/src/utils.ts +0 -19
package/dist/api.js
CHANGED
|
@@ -20,7 +20,7 @@ export default class RequestProvider {
|
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
getPendingTransactions(safeAddress, nonce) {
|
|
23
|
-
return this.request.get(`/safes/${safeAddress}/multisig-transactions/`, {
|
|
23
|
+
return this.request.get(`/safes/${toChecksumAddress(safeAddress)}/multisig-transactions/`, {
|
|
24
24
|
params: {
|
|
25
25
|
executed: false,
|
|
26
26
|
nonce__gte: nonce,
|
|
@@ -31,7 +31,7 @@ export default class RequestProvider {
|
|
|
31
31
|
return this.request.post(`/safes/${toChecksumAddress(safeAddres)}/multisig-transactions/`, data);
|
|
32
32
|
}
|
|
33
33
|
getSafeInfo(safeAddress) {
|
|
34
|
-
return this.request.get(`/safes/${safeAddress}/`);
|
|
34
|
+
return this.request.get(`/safes/${toChecksumAddress(safeAddress)}/`);
|
|
35
35
|
}
|
|
36
36
|
confirmTransaction(hash, data) {
|
|
37
37
|
return this.request.post(`/multisig-transactions/${hash}/confirmations/`, data);
|
package/dist/index.d.ts
CHANGED
|
@@ -16,13 +16,13 @@ declare class Safe {
|
|
|
16
16
|
network: string;
|
|
17
17
|
constructor(safeAddress: string, version: string, provider: providers.Web3Provider, network?: string);
|
|
18
18
|
static getSafeInfo(safeAddress: string, network: string): Promise<SafeInfo>;
|
|
19
|
+
static getPendingTransactions(safeAddress: string, network: string): Promise<{
|
|
20
|
+
results: import("./api").SafeTransactionItem[];
|
|
21
|
+
}>;
|
|
19
22
|
init(): Promise<void>;
|
|
20
23
|
getOwners(): Promise<string[]>;
|
|
21
24
|
getThreshold(): Promise<any>;
|
|
22
25
|
getNonce(): Promise<number>;
|
|
23
|
-
getPendingTransactions(): Promise<{
|
|
24
|
-
results: import("./api").SafeTransactionItem[];
|
|
25
|
-
}>;
|
|
26
26
|
buildTransaction(data: SafeTransactionDataPartial): Promise<SafeTransaction>;
|
|
27
27
|
getTransactionHash(transaction: SafeTransaction): Promise<any>;
|
|
28
28
|
signTransactionHash(hash: string): Promise<SafeSignature>;
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Contract } from "ethers";
|
|
2
2
|
import { BigNumber } from "@ethersproject/bignumber";
|
|
3
|
+
import BN from 'bignumber.js';
|
|
3
4
|
import { getSafeSingletonDeployment } from "@gnosis.pm/safe-deployments";
|
|
4
5
|
import { toChecksumAddress } from "web3-utils";
|
|
5
6
|
import SafeTransaction from "@gnosis.pm/safe-core-sdk/dist/src/utils/transactions/SafeTransaction";
|
|
6
7
|
import RequestProvider from "./api";
|
|
7
|
-
import { standardizeSafeTransactionData, sameString, generateSignature, generatePreValidatedSignature, estimateGasForTransactionExecution,
|
|
8
|
+
import { standardizeSafeTransactionData, sameString, generateSignature, generatePreValidatedSignature, estimateGasForTransactionExecution, } from "./utils";
|
|
8
9
|
class Safe {
|
|
9
10
|
constructor(safeAddress, version, provider, network = "1") {
|
|
10
11
|
this.owners = [];
|
|
@@ -26,7 +27,13 @@ class Safe {
|
|
|
26
27
|
}
|
|
27
28
|
static getSafeInfo(safeAddress, network) {
|
|
28
29
|
const request = new RequestProvider(network);
|
|
29
|
-
return request.getSafeInfo(safeAddress);
|
|
30
|
+
return request.getSafeInfo(toChecksumAddress(safeAddress));
|
|
31
|
+
}
|
|
32
|
+
static async getPendingTransactions(safeAddress, network) {
|
|
33
|
+
const request = new RequestProvider(network);
|
|
34
|
+
const nonce = (await request.getSafeInfo(toChecksumAddress(safeAddress))).nonce;
|
|
35
|
+
const transactions = await request.getPendingTransactions(safeAddress, nonce);
|
|
36
|
+
return transactions;
|
|
30
37
|
}
|
|
31
38
|
async init() {
|
|
32
39
|
const safeInfo = await Safe.getSafeInfo(this.safeAddress, this.network);
|
|
@@ -49,11 +56,6 @@ class Safe {
|
|
|
49
56
|
const nonce = await this.contract.nonce();
|
|
50
57
|
return nonce.toNumber();
|
|
51
58
|
}
|
|
52
|
-
async getPendingTransactions() {
|
|
53
|
-
const nonce = await this.getNonce();
|
|
54
|
-
const transactions = await this.request.getPendingTransactions(this.safeAddress, nonce);
|
|
55
|
-
return transactions;
|
|
56
|
-
}
|
|
57
59
|
async buildTransaction(data) {
|
|
58
60
|
const transaction = await standardizeSafeTransactionData(this.safeAddress, this.contract, this.provider, data);
|
|
59
61
|
return new SafeTransaction(transaction);
|
|
@@ -95,7 +97,7 @@ class Safe {
|
|
|
95
97
|
await this.request.postTransactions(this.safeAddress, {
|
|
96
98
|
safe: safeAddress,
|
|
97
99
|
to: toChecksumAddress(transaction.data.to),
|
|
98
|
-
value:
|
|
100
|
+
value: new BN(transaction.data.value).toFixed(),
|
|
99
101
|
data: transaction.data.data,
|
|
100
102
|
operation: transaction.data.operation,
|
|
101
103
|
gasToken: transaction.data.gasToken,
|
|
@@ -155,7 +157,7 @@ class Safe {
|
|
|
155
157
|
from: signerAddress,
|
|
156
158
|
};
|
|
157
159
|
const txResponse = await contract.execTransaction(safeTransaction.data.to, safeTransaction.data.value, safeTransaction.data.data, safeTransaction.data.operation, safeTransaction.data.safeTxGas, safeTransaction.data.baseGas, safeTransaction.data.gasPrice, safeTransaction.data.gasToken, safeTransaction.data.refundReceiver, safeTransaction.encodedSignatures(), executionOptions);
|
|
158
|
-
return
|
|
160
|
+
return txResponse;
|
|
159
161
|
}
|
|
160
162
|
}
|
|
161
163
|
export default Safe;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Contract, providers } from "ethers";
|
|
2
2
|
import { OperationType, SafeTransactionData, SafeTransactionDataPartial, SafeSignature, SafeTransaction } from "@gnosis.pm/safe-core-sdk-types";
|
|
3
|
-
import { TransactionOptions, Web3TransactionResult } from "@gnosis.pm/safe-core-sdk/dist/src/utils/transactions/types";
|
|
4
|
-
import { PromiEvent, TransactionReceipt } from "web3-core/types";
|
|
5
3
|
import EthSignSignature from "@gnosis.pm/safe-core-sdk/dist/src/utils/signatures/SafeSignature";
|
|
6
4
|
export declare function sameString(str1: string, str2: string): boolean;
|
|
7
5
|
export declare function isRestrictedAddress(address: string): boolean;
|
|
@@ -12,4 +10,3 @@ export declare function isTxHashSignedWithPrefix(txHash: string, signature: stri
|
|
|
12
10
|
export declare function adjustVInSignature(signature: string, hasPrefix: boolean): string;
|
|
13
11
|
export declare function generateSignature(provider: providers.Web3Provider, hash: string): Promise<EthSignSignature>;
|
|
14
12
|
export declare function estimateGasForTransactionExecution(safeContract: Contract, from: string, tx: SafeTransaction): Promise<number>;
|
|
15
|
-
export declare function toTxResult(promiEvent: PromiEvent<TransactionReceipt>, options?: TransactionOptions): Promise<Web3TransactionResult>;
|
package/dist/utils.js
CHANGED
|
@@ -154,8 +154,3 @@ export async function estimateGasForTransactionExecution(safeContract, from, tx)
|
|
|
154
154
|
return Promise.reject(error);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
export function toTxResult(promiEvent, options) {
|
|
158
|
-
return new Promise((resolve, reject) => promiEvent
|
|
159
|
-
.once("transactionHash", (hash) => resolve({ hash, promiEvent, options }))
|
|
160
|
-
.catch(reject));
|
|
161
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rabby-wallet/gnosis-sdk",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"@gnosis.pm/safe-core-sdk-types": "^0.1.1",
|
|
19
19
|
"@gnosis.pm/safe-deployments": "^1.4.0",
|
|
20
20
|
"axios": "^0.24.0",
|
|
21
|
+
"bignumber.js": "^9.0.2",
|
|
21
22
|
"ethereumjs-util": "^7.1.3",
|
|
22
23
|
"ethers": "^5.5.1",
|
|
23
24
|
"typescript": "^4.4.4",
|
package/src/api.ts
CHANGED
|
@@ -76,7 +76,7 @@ export default class RequestProvider {
|
|
|
76
76
|
safeAddress: string,
|
|
77
77
|
nonce: number
|
|
78
78
|
): Promise<{ results: SafeTransactionItem[] }> {
|
|
79
|
-
return this.request.get(`/safes/${safeAddress}/multisig-transactions/`, {
|
|
79
|
+
return this.request.get(`/safes/${toChecksumAddress(safeAddress)}/multisig-transactions/`, {
|
|
80
80
|
params: {
|
|
81
81
|
executed: false,
|
|
82
82
|
nonce__gte: nonce,
|
|
@@ -92,7 +92,7 @@ export default class RequestProvider {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
getSafeInfo(safeAddress: string): Promise<SafeInfo> {
|
|
95
|
-
return this.request.get(`/safes/${safeAddress}/`);
|
|
95
|
+
return this.request.get(`/safes/${toChecksumAddress(safeAddress)}/`);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
confirmTransaction(hash: string, data): Promise<void> {
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Contract } from "ethers";
|
|
2
2
|
import { BigNumber } from "@ethersproject/bignumber";
|
|
3
|
+
import BN from 'bignumber.js';
|
|
3
4
|
import { getSafeSingletonDeployment } from "@gnosis.pm/safe-deployments";
|
|
4
5
|
import { providers } from "ethers";
|
|
5
6
|
import { toChecksumAddress } from "web3-utils";
|
|
@@ -19,7 +20,6 @@ import {
|
|
|
19
20
|
generateSignature,
|
|
20
21
|
generatePreValidatedSignature,
|
|
21
22
|
estimateGasForTransactionExecution,
|
|
22
|
-
toTxResult,
|
|
23
23
|
} from "./utils";
|
|
24
24
|
|
|
25
25
|
class Safe {
|
|
@@ -56,7 +56,18 @@ class Safe {
|
|
|
56
56
|
|
|
57
57
|
static getSafeInfo(safeAddress: string, network: string) {
|
|
58
58
|
const request = new RequestProvider(network);
|
|
59
|
-
return request.getSafeInfo(safeAddress);
|
|
59
|
+
return request.getSafeInfo(toChecksumAddress(safeAddress));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static async getPendingTransactions(safeAddress: string, network: string) {
|
|
63
|
+
const request = new RequestProvider(network);
|
|
64
|
+
const nonce = (await request.getSafeInfo(toChecksumAddress(safeAddress))).nonce;
|
|
65
|
+
const transactions = await request.getPendingTransactions(
|
|
66
|
+
safeAddress,
|
|
67
|
+
nonce
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return transactions;
|
|
60
71
|
}
|
|
61
72
|
|
|
62
73
|
async init() {
|
|
@@ -87,13 +98,6 @@ class Safe {
|
|
|
87
98
|
return nonce.toNumber();
|
|
88
99
|
}
|
|
89
100
|
|
|
90
|
-
async getPendingTransactions() {
|
|
91
|
-
const nonce = await this.getNonce();
|
|
92
|
-
const transactions = await this.request.getPendingTransactions(this.safeAddress, nonce);
|
|
93
|
-
|
|
94
|
-
return transactions;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
101
|
async buildTransaction(data: SafeTransactionDataPartial) {
|
|
98
102
|
const transaction = await standardizeSafeTransactionData(
|
|
99
103
|
this.safeAddress,
|
|
@@ -158,7 +162,7 @@ class Safe {
|
|
|
158
162
|
await this.request.postTransactions(this.safeAddress, {
|
|
159
163
|
safe: safeAddress,
|
|
160
164
|
to: toChecksumAddress(transaction.data.to),
|
|
161
|
-
value:
|
|
165
|
+
value: new BN(transaction.data.value).toFixed(),
|
|
162
166
|
data: transaction.data.data,
|
|
163
167
|
operation: transaction.data.operation,
|
|
164
168
|
gasToken: transaction.data.gasToken,
|
|
@@ -251,9 +255,9 @@ class Safe {
|
|
|
251
255
|
safeTransaction.data.refundReceiver,
|
|
252
256
|
safeTransaction.encodedSignatures(),
|
|
253
257
|
executionOptions
|
|
254
|
-
)
|
|
258
|
+
);
|
|
255
259
|
|
|
256
|
-
return
|
|
260
|
+
return txResponse;
|
|
257
261
|
}
|
|
258
262
|
}
|
|
259
263
|
|
package/src/utils.ts
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import { BigNumber } from "@ethersproject/bignumber";
|
|
2
2
|
import { Contract, providers } from "ethers";
|
|
3
3
|
import {
|
|
4
|
-
MetaTransactionData,
|
|
5
4
|
OperationType,
|
|
6
5
|
SafeTransactionData,
|
|
7
6
|
SafeTransactionDataPartial,
|
|
8
7
|
SafeSignature,
|
|
9
8
|
SafeTransaction,
|
|
10
9
|
} from "@gnosis.pm/safe-core-sdk-types";
|
|
11
|
-
import {
|
|
12
|
-
TransactionOptions,
|
|
13
|
-
Web3TransactionResult,
|
|
14
|
-
} from "@gnosis.pm/safe-core-sdk/dist/src/utils/transactions/types";
|
|
15
|
-
import { PromiEvent, TransactionReceipt } from "web3-core/types";
|
|
16
10
|
import { bufferToHex, ecrecover, pubToAddress } from "ethereumjs-util";
|
|
17
11
|
import { ZERO_ADDRESS, SENTINEL_ADDRESS } from "./constants";
|
|
18
12
|
import EthSignSignature from "@gnosis.pm/safe-core-sdk/dist/src/utils/signatures/SafeSignature";
|
|
@@ -236,16 +230,3 @@ export async function estimateGasForTransactionExecution(
|
|
|
236
230
|
return Promise.reject(error);
|
|
237
231
|
}
|
|
238
232
|
}
|
|
239
|
-
|
|
240
|
-
export function toTxResult(
|
|
241
|
-
promiEvent: PromiEvent<TransactionReceipt>,
|
|
242
|
-
options?: TransactionOptions
|
|
243
|
-
): Promise<Web3TransactionResult> {
|
|
244
|
-
return new Promise((resolve, reject) =>
|
|
245
|
-
promiEvent
|
|
246
|
-
.once("transactionHash", (hash: string) =>
|
|
247
|
-
resolve({ hash, promiEvent, options })
|
|
248
|
-
)
|
|
249
|
-
.catch(reject)
|
|
250
|
-
);
|
|
251
|
-
}
|