@gnosis.pm/safe-apps-sdk
Advanced tools
Comparing version 2.1.0 to 2.2.0
{ | ||
"name": "@gnosis.pm/safe-apps-sdk", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "SDK developed to integrate third-party apps with Safe-Multisig app.", | ||
@@ -27,4 +27,3 @@ "main": "dist/src/index.js", | ||
"dependencies": { | ||
"semver": "^7.3.2", | ||
"web3-core": "^1.3.0" | ||
"semver": "^7.3.2" | ||
}, | ||
@@ -41,5 +40,2 @@ "devDependencies": { | ||
}, | ||
"peerDependencies": { | ||
"web3-core": "^1.3.0" | ||
}, | ||
"husky": { | ||
@@ -46,0 +42,0 @@ "hooks": { |
@@ -1,4 +0,2 @@ | ||
import { TransactionConfig, PastLogsOptions } from 'web3-core'; | ||
import { Communicator, Log, BlockTransactionString, BlockTransactionObject, Web3TransactionObject, Web3TransactionReceiptObject } from '../types'; | ||
declare type BlockNumberArg = number | 'earliest' | 'latest' | 'pending'; | ||
import { BlockNumberArg, Communicator, Log, BlockTransactionString, BlockTransactionObject, Web3TransactionObject, TransactionConfig, Web3TransactionReceiptObject, PastLogsOptions } from '../types'; | ||
declare class Eth { | ||
@@ -5,0 +3,0 @@ #private; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) { | ||
@@ -73,3 +64,3 @@ if (!privateMap.has(receiver)) { | ||
buildRequest({ call, formatters }) { | ||
return (params) => __awaiter(this, void 0, void 0, function* () { | ||
return async (params) => { | ||
if (formatters && Array.isArray(params)) { | ||
@@ -86,3 +77,3 @@ formatters.forEach((formatter, i) => { | ||
}; | ||
const response = yield __classPrivateFieldGet(this, _communicator).send(methods_1.METHODS.rpcCall, payload); | ||
const response = await __classPrivateFieldGet(this, _communicator).send(methods_1.METHODS.rpcCall, payload); | ||
if (!response.success) { | ||
@@ -92,3 +83,3 @@ throw new Error(response.error); | ||
return response.data; | ||
}); | ||
}; | ||
} | ||
@@ -95,0 +86,0 @@ } |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) { | ||
@@ -45,25 +36,19 @@ if (!privateMap.has(receiver)) { | ||
} | ||
bootstrap() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { txServiceUrl } = yield this.getEnvInfo(); | ||
this.txs.setTxServiceUrl(txServiceUrl); | ||
}); | ||
async bootstrap() { | ||
const { txServiceUrl } = await this.getEnvInfo(); | ||
this.txs.setTxServiceUrl(txServiceUrl); | ||
} | ||
getEnvInfo() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield __classPrivateFieldGet(this, _communicator).send(communication_1.METHODS.getEnvInfo, undefined); | ||
if (!response.success) { | ||
throw new Error(response.error); | ||
} | ||
return response.data; | ||
}); | ||
async getEnvInfo() { | ||
const response = await __classPrivateFieldGet(this, _communicator).send(communication_1.METHODS.getEnvInfo, undefined); | ||
if (!response.success) { | ||
throw new Error(response.error); | ||
} | ||
return response.data; | ||
} | ||
getSafeInfo() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield __classPrivateFieldGet(this, _communicator).send(communication_1.METHODS.getSafeInfo, undefined); | ||
if (!response.success) { | ||
throw new Error(response.error); | ||
} | ||
return response.data; | ||
}); | ||
async getSafeInfo() { | ||
const response = await __classPrivateFieldGet(this, _communicator).send(communication_1.METHODS.getSafeInfo, undefined); | ||
if (!response.success) { | ||
throw new Error(response.error); | ||
} | ||
return response.data; | ||
} | ||
@@ -70,0 +55,0 @@ } |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) { | ||
@@ -34,41 +25,37 @@ if (!privateMap.has(receiver)) { | ||
} | ||
getBySafeTxHash(safeTxHash) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!__classPrivateFieldGet(this, _txServiceUrl)) { | ||
throw new Error("ENV information hasn't been synced yet or there was an error during the process"); | ||
async getBySafeTxHash(safeTxHash) { | ||
if (!__classPrivateFieldGet(this, _txServiceUrl)) { | ||
throw new Error("ENV information hasn't been synced yet or there was an error during the process"); | ||
} | ||
const controller = new AbortController(); | ||
const options = { | ||
method: 'GET', | ||
signal: controller.signal, | ||
}; | ||
setTimeout(() => controller.abort(), 10000); | ||
try { | ||
const res = await fetch(`${__classPrivateFieldGet(this, _txServiceUrl)}/transactions/${safeTxHash}`, options); | ||
if (res.status !== 200) { | ||
throw new Error("Failed to get the transaction. Either safeTxHash is incorrect or transaction hasn't been indexed by the service yet"); | ||
} | ||
const controller = new AbortController(); | ||
const options = { | ||
method: 'GET', | ||
signal: controller.signal, | ||
}; | ||
setTimeout(() => controller.abort(), 10000); | ||
try { | ||
const res = yield fetch(`${__classPrivateFieldGet(this, _txServiceUrl)}/transactions/${safeTxHash}`, options); | ||
if (res.status !== 200) { | ||
throw new Error("Failed to get the transaction. Either safeTxHash is incorrect or transaction hasn't been indexed by the service yet"); | ||
} | ||
const json = yield res.json(); | ||
return json; | ||
} | ||
catch (err) { | ||
throw err; | ||
} | ||
}); | ||
const json = await res.json(); | ||
return json; | ||
} | ||
catch (err) { | ||
throw err; | ||
} | ||
} | ||
send({ txs, params }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!txs || !txs.length) { | ||
throw new Error('No transactions were passed'); | ||
} | ||
const messagePayload = { | ||
txs, | ||
params, | ||
}; | ||
const response = yield __classPrivateFieldGet(this, _communicator).send(methods_1.METHODS.sendTransactions, messagePayload); | ||
if (!response.success) { | ||
throw new Error(response.error); | ||
} | ||
return response.data; | ||
}); | ||
async send({ txs, params }) { | ||
if (!txs || !txs.length) { | ||
throw new Error('No transactions were passed'); | ||
} | ||
const messagePayload = { | ||
txs, | ||
params, | ||
}; | ||
const response = await __classPrivateFieldGet(this, _communicator).send(methods_1.METHODS.sendTransactions, messagePayload); | ||
if (!response.success) { | ||
throw new Error(response.error); | ||
} | ||
return response.data; | ||
} | ||
@@ -75,0 +62,0 @@ setTxServiceUrl(url) { |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -28,5 +19,5 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
describe('SDK.txs.send', () => { | ||
test('Should throw an error when passing an empty array', () => __awaiter(void 0, void 0, void 0, function* () { | ||
yield expect(sdkInstance.txs.send({ txs: [] })).rejects.toEqual(new Error('No transactions were passed')); | ||
})); | ||
test('Should throw an error when passing an empty array', async () => { | ||
await expect(sdkInstance.txs.send({ txs: [] })).rejects.toEqual(new Error('No transactions were passed')); | ||
}); | ||
test('Should call window.parent.postMessage when passing array of TXs', () => { | ||
@@ -33,0 +24,0 @@ const txs = [{ to: 'address', value: '0', data: '0x' }]; |
@@ -221,1 +221,17 @@ import { METHODS } from './communication/methods'; | ||
} | ||
export declare type BlockNumberArg = number | 'earliest' | 'latest' | 'pending'; | ||
export interface TransactionConfig { | ||
from?: string | number; | ||
to?: string; | ||
value?: number | string; | ||
gas?: number | string; | ||
gasPrice?: number | string; | ||
data?: string; | ||
nonce?: number; | ||
} | ||
export interface PastLogsOptions { | ||
fromBlock?: BlockNumberArg; | ||
toBlock?: BlockNumberArg; | ||
address?: string; | ||
topics?: Array<string | string[] | null>; | ||
} |
{ | ||
"name": "@gnosis.pm/safe-apps-sdk", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "SDK developed to integrate third-party apps with Safe-Multisig app.", | ||
@@ -27,4 +27,3 @@ "main": "dist/src/index.js", | ||
"dependencies": { | ||
"semver": "^7.3.2", | ||
"web3-core": "^1.3.0" | ||
"semver": "^7.3.2" | ||
}, | ||
@@ -41,5 +40,2 @@ "devDependencies": { | ||
}, | ||
"peerDependencies": { | ||
"web3-core": "^1.3.0" | ||
}, | ||
"husky": { | ||
@@ -46,0 +42,0 @@ "hooks": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1
1
76451
1025
- Removedweb3-core@^1.3.0
- Removed@ethereumjs/rlp@4.0.1(transitive)
- Removed@ethereumjs/util@8.1.0(transitive)
- Removed@ethersproject/address@5.7.0(transitive)
- Removed@ethersproject/bignumber@5.7.0(transitive)
- Removed@ethersproject/bytes@5.7.0(transitive)
- Removed@ethersproject/constants@5.7.0(transitive)
- Removed@ethersproject/keccak256@5.7.0(transitive)
- Removed@ethersproject/logger@5.7.0(transitive)
- Removed@ethersproject/properties@5.7.0(transitive)
- Removed@ethersproject/rlp@5.7.0(transitive)
- Removed@ethersproject/signing-key@5.7.0(transitive)
- Removed@ethersproject/transactions@5.7.0(transitive)
- Removed@noble/curves@1.4.2(transitive)
- Removed@noble/hashes@1.4.01.7.1(transitive)
- Removed@scure/base@1.1.9(transitive)
- Removed@scure/bip32@1.4.0(transitive)
- Removed@scure/bip39@1.3.0(transitive)
- Removed@types/bn.js@5.1.6(transitive)
- Removed@types/node@12.20.55(transitive)
- Removedabortcontroller-polyfill@1.7.8(transitive)
- Removedavailable-typed-arrays@1.0.7(transitive)
- Removedbignumber.js@9.1.2(transitive)
- Removedbn.js@4.11.64.12.15.2.1(transitive)
- Removedbrorand@1.1.0(transitive)
- Removedbufferutil@4.0.9(transitive)
- Removedcall-bind@1.0.8(transitive)
- Removedcall-bind-apply-helpers@1.0.2(transitive)
- Removedcall-bound@1.0.3(transitive)
- Removedcross-fetch@4.1.0(transitive)
- Removedd@1.0.2(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddunder-proto@1.0.1(transitive)
- Removedelliptic@6.5.4(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.1.1(transitive)
- Removedes5-ext@0.10.64(transitive)
- Removedes6-iterator@2.0.3(transitive)
- Removedes6-promise@4.2.8(transitive)
- Removedes6-symbol@3.1.4(transitive)
- Removedesniff@2.0.1(transitive)
- Removedethereum-bloom-filters@1.2.0(transitive)
- Removedethereum-cryptography@2.2.1(transitive)
- Removedethjs-unit@0.1.6(transitive)
- Removedevent-emitter@0.3.5(transitive)
- Removedeventemitter3@4.0.4(transitive)
- Removedext@1.7.0(transitive)
- Removedfor-each@0.3.5(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.7(transitive)
- Removedget-proto@1.0.1(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhash.js@1.1.7(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhmac-drbg@1.0.1(transitive)
- Removedhttp-https@1.0.0(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-arguments@1.2.0(transitive)
- Removedis-callable@1.2.7(transitive)
- Removedis-generator-function@1.1.0(transitive)
- Removedis-hex-prefixed@1.0.0(transitive)
- Removedis-regex@1.2.1(transitive)
- Removedis-typed-array@1.1.15(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedjs-sha3@0.8.0(transitive)
- Removedmath-intrinsics@1.1.0(transitive)
- Removedmicro-ftch@0.3.1(transitive)
- Removedminimalistic-assert@1.0.1(transitive)
- Removedminimalistic-crypto-utils@1.0.1(transitive)
- Removedms@2.0.0(transitive)
- Removednext-tick@1.1.0(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removednode-gyp-build@4.8.4(transitive)
- Removednumber-to-bn@1.7.0(transitive)
- Removedoboe@2.1.5(transitive)
- Removedpossible-typed-array-names@1.1.0(transitive)
- Removedrandombytes@2.1.0(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafe-regex-test@1.1.0(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedstrip-hex-prefix@1.0.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removedtype@2.7.3(transitive)
- Removedtypedarray-to-buffer@3.1.5(transitive)
- Removedutf-8-validate@5.0.10(transitive)
- Removedutf8@3.0.0(transitive)
- Removedutil@0.12.5(transitive)
- Removedweb3-core@1.10.4(transitive)
- Removedweb3-core-helpers@1.10.4(transitive)
- Removedweb3-core-method@1.10.4(transitive)
- Removedweb3-core-promievent@1.10.4(transitive)
- Removedweb3-core-requestmanager@1.10.4(transitive)
- Removedweb3-core-subscriptions@1.10.4(transitive)
- Removedweb3-eth-iban@1.10.4(transitive)
- Removedweb3-providers-http@1.10.4(transitive)
- Removedweb3-providers-ipc@1.10.4(transitive)
- Removedweb3-providers-ws@1.10.4(transitive)
- Removedweb3-utils@1.10.4(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwebsocket@1.0.35(transitive)
- Removedwhatwg-url@5.0.0(transitive)
- Removedwhich-typed-array@1.1.18(transitive)
- Removedyaeti@0.0.6(transitive)