@0xsequence/transactions
Advanced tools
Comparing version 0.42.10 to 0.43.0
@@ -6,11 +6,9 @@ 'use strict'; | ||
var ethers = require('ethers'); | ||
var abi = require('@ethersproject/abi'); | ||
var abi$1 = require('@0xsequence/abi'); | ||
var abi = require('@0xsequence/abi'); | ||
var utils = require('@0xsequence/utils'); | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
@@ -22,6 +20,4 @@ if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
@@ -59,8 +55,10 @@ } | ||
// Bundles all transactions, including the auxiliary ones | ||
const allTxs = flattenAuxTransactions(txs); // Uses the lowest nonce found on TransactionRequest | ||
const allTxs = flattenAuxTransactions(txs); | ||
// Uses the lowest nonce found on TransactionRequest | ||
// if there are no nonces, it leaves an undefined nonce | ||
const nonces = (await Promise.all(txs.map(t => t.nonce))).filter(n => n !== undefined).map(n => ethers.ethers.BigNumber.from(n)); | ||
const nonce = nonces.length !== 0 ? nonces.reduce((p, c) => p.lt(c) ? p : c) : undefined; // Maps all transactions into SequenceTransactions | ||
const nonce = nonces.length !== 0 ? nonces.reduce((p, c) => p.lt(c) ? p : c) : undefined; | ||
// Maps all transactions into SequenceTransactions | ||
return Promise.all(allTxs.map(tx => toSequenceTransaction(wallet, tx, revertOnError, gasLimit, nonce))); | ||
@@ -72,7 +70,4 @@ } | ||
const aux = txs.auxiliary; | ||
const tx = _extends({}, txs); | ||
delete tx.auxiliary; | ||
if (aux) { | ||
@@ -87,3 +82,2 @@ return [tx, ...flattenAuxTransactions(aux)]; | ||
} | ||
return txs.flatMap(flattenAuxTransactions); | ||
@@ -95,5 +89,3 @@ } | ||
} | ||
const txGas = tx.gasLimit === undefined ? tx.gas : tx.gasLimit; | ||
if (tx.to) { | ||
@@ -110,3 +102,3 @@ return { | ||
} else { | ||
const walletInterface = new abi.Interface(abi$1.walletContracts.mainModule.abi); | ||
const walletInterface = new ethers.utils.Interface(abi.walletContracts.mainModule.abi); | ||
const data = walletInterface.encodeFunctionData(walletInterface.getFunction('createContract'), [tx.data]); | ||
@@ -136,13 +128,9 @@ const address = typeof wallet === 'string' ? wallet : wallet.getAddress(); | ||
const sample = txs.find(t => t.nonce !== undefined); | ||
if (!sample) { | ||
return undefined; | ||
} | ||
const sampleNonce = ethers.ethers.BigNumber.from(sample.nonce); | ||
if (txs.find(t => t.nonce !== undefined && !ethers.ethers.BigNumber.from(t.nonce).eq(sampleNonce))) { | ||
throw new Error('Mixed nonces on Sequence transactions'); | ||
} | ||
return sample ? sample.nonce : undefined; | ||
@@ -153,3 +141,2 @@ } | ||
var _t$to; | ||
return { | ||
@@ -171,8 +158,6 @@ delegateCall: t.delegateCall === true, | ||
function makeExpirable(context, txs, expiration) { | ||
const sequenceUtils = new abi.Interface(abi$1.walletContracts.sequenceUtils.abi); | ||
const sequenceUtils = new ethers.utils.Interface(abi.walletContracts.sequenceUtils.abi); | ||
if (!context || !context.sequenceUtils) { | ||
throw new Error('Undefined sequenceUtils'); | ||
} | ||
return [{ | ||
@@ -188,8 +173,6 @@ delegateCall: false, | ||
function makeAfterNonce(context, txs, dep) { | ||
const sequenceUtils = new abi.Interface(abi$1.walletContracts.sequenceUtils.abi); | ||
const sequenceUtils = new ethers.utils.Interface(abi.walletContracts.sequenceUtils.abi); | ||
if (!context || !context.sequenceUtils) { | ||
throw new Error('Undefined sequenceUtils'); | ||
} | ||
return [{ | ||
@@ -208,7 +191,5 @@ delegateCall: false, | ||
const shl = ethers.ethers.constants.Two.pow(ethers.ethers.BigNumber.from(96)); | ||
if (!bnonce.div(shl).eq(ethers.ethers.constants.Zero)) { | ||
throw new Error('Space already encoded'); | ||
} | ||
return bnonce.add(bspace.mul(shl)); | ||
@@ -226,3 +207,2 @@ } | ||
let stx = []; | ||
if (Array.isArray(transaction)) { | ||
@@ -238,12 +218,12 @@ if (hasSequenceTransactions(transaction)) { | ||
stx = await toSequenceTransactions(wallet, [transaction]); | ||
} // If transaction is marked as expirable | ||
} | ||
// If transaction is marked as expirable | ||
// append expirable require | ||
if (transaction.expiration) { | ||
stx = makeExpirable(context, stx, transaction.expiration); | ||
} // If transaction depends on another nonce | ||
} | ||
// If transaction depends on another nonce | ||
// append after nonce requirement | ||
if (transaction.afterNonce) { | ||
@@ -260,3 +240,2 @@ const after = transaction.afterNonce; | ||
} | ||
return stx; | ||
@@ -263,0 +242,0 @@ } |
@@ -6,11 +6,9 @@ 'use strict'; | ||
var ethers = require('ethers'); | ||
var abi = require('@ethersproject/abi'); | ||
var abi$1 = require('@0xsequence/abi'); | ||
var abi = require('@0xsequence/abi'); | ||
var utils = require('@0xsequence/utils'); | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
@@ -22,6 +20,4 @@ if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
@@ -59,8 +55,10 @@ } | ||
// Bundles all transactions, including the auxiliary ones | ||
const allTxs = flattenAuxTransactions(txs); // Uses the lowest nonce found on TransactionRequest | ||
const allTxs = flattenAuxTransactions(txs); | ||
// Uses the lowest nonce found on TransactionRequest | ||
// if there are no nonces, it leaves an undefined nonce | ||
const nonces = (await Promise.all(txs.map(t => t.nonce))).filter(n => n !== undefined).map(n => ethers.ethers.BigNumber.from(n)); | ||
const nonce = nonces.length !== 0 ? nonces.reduce((p, c) => p.lt(c) ? p : c) : undefined; // Maps all transactions into SequenceTransactions | ||
const nonce = nonces.length !== 0 ? nonces.reduce((p, c) => p.lt(c) ? p : c) : undefined; | ||
// Maps all transactions into SequenceTransactions | ||
return Promise.all(allTxs.map(tx => toSequenceTransaction(wallet, tx, revertOnError, gasLimit, nonce))); | ||
@@ -72,7 +70,4 @@ } | ||
const aux = txs.auxiliary; | ||
const tx = _extends({}, txs); | ||
delete tx.auxiliary; | ||
if (aux) { | ||
@@ -87,3 +82,2 @@ return [tx, ...flattenAuxTransactions(aux)]; | ||
} | ||
return txs.flatMap(flattenAuxTransactions); | ||
@@ -95,5 +89,3 @@ } | ||
} | ||
const txGas = tx.gasLimit === undefined ? tx.gas : tx.gasLimit; | ||
if (tx.to) { | ||
@@ -110,3 +102,3 @@ return { | ||
} else { | ||
const walletInterface = new abi.Interface(abi$1.walletContracts.mainModule.abi); | ||
const walletInterface = new ethers.utils.Interface(abi.walletContracts.mainModule.abi); | ||
const data = walletInterface.encodeFunctionData(walletInterface.getFunction('createContract'), [tx.data]); | ||
@@ -136,13 +128,9 @@ const address = typeof wallet === 'string' ? wallet : wallet.getAddress(); | ||
const sample = txs.find(t => t.nonce !== undefined); | ||
if (!sample) { | ||
return undefined; | ||
} | ||
const sampleNonce = ethers.ethers.BigNumber.from(sample.nonce); | ||
if (txs.find(t => t.nonce !== undefined && !ethers.ethers.BigNumber.from(t.nonce).eq(sampleNonce))) { | ||
throw new Error('Mixed nonces on Sequence transactions'); | ||
} | ||
return sample ? sample.nonce : undefined; | ||
@@ -153,3 +141,2 @@ } | ||
var _t$to; | ||
return { | ||
@@ -171,8 +158,6 @@ delegateCall: t.delegateCall === true, | ||
function makeExpirable(context, txs, expiration) { | ||
const sequenceUtils = new abi.Interface(abi$1.walletContracts.sequenceUtils.abi); | ||
const sequenceUtils = new ethers.utils.Interface(abi.walletContracts.sequenceUtils.abi); | ||
if (!context || !context.sequenceUtils) { | ||
throw new Error('Undefined sequenceUtils'); | ||
} | ||
return [{ | ||
@@ -188,8 +173,6 @@ delegateCall: false, | ||
function makeAfterNonce(context, txs, dep) { | ||
const sequenceUtils = new abi.Interface(abi$1.walletContracts.sequenceUtils.abi); | ||
const sequenceUtils = new ethers.utils.Interface(abi.walletContracts.sequenceUtils.abi); | ||
if (!context || !context.sequenceUtils) { | ||
throw new Error('Undefined sequenceUtils'); | ||
} | ||
return [{ | ||
@@ -208,7 +191,5 @@ delegateCall: false, | ||
const shl = ethers.ethers.constants.Two.pow(ethers.ethers.BigNumber.from(96)); | ||
if (!bnonce.div(shl).eq(ethers.ethers.constants.Zero)) { | ||
throw new Error('Space already encoded'); | ||
} | ||
return bnonce.add(bspace.mul(shl)); | ||
@@ -226,3 +207,2 @@ } | ||
let stx = []; | ||
if (Array.isArray(transaction)) { | ||
@@ -238,12 +218,12 @@ if (hasSequenceTransactions(transaction)) { | ||
stx = await toSequenceTransactions(wallet, [transaction]); | ||
} // If transaction is marked as expirable | ||
} | ||
// If transaction is marked as expirable | ||
// append expirable require | ||
if (transaction.expiration) { | ||
stx = makeExpirable(context, stx, transaction.expiration); | ||
} // If transaction depends on another nonce | ||
} | ||
// If transaction depends on another nonce | ||
// append after nonce requirement | ||
if (transaction.afterNonce) { | ||
@@ -260,3 +240,2 @@ const after = transaction.afterNonce; | ||
} | ||
return stx; | ||
@@ -263,0 +242,0 @@ } |
@@ -1,3 +0,2 @@ | ||
import { ethers } from 'ethers'; | ||
import { Interface } from '@ethersproject/abi'; | ||
import { ethers, utils } from 'ethers'; | ||
import { walletContracts } from '@0xsequence/abi'; | ||
@@ -7,6 +6,5 @@ import { subDigestOf } from '@0xsequence/utils'; | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
@@ -18,6 +16,4 @@ if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
@@ -55,8 +51,10 @@ } | ||
// Bundles all transactions, including the auxiliary ones | ||
const allTxs = flattenAuxTransactions(txs); // Uses the lowest nonce found on TransactionRequest | ||
const allTxs = flattenAuxTransactions(txs); | ||
// Uses the lowest nonce found on TransactionRequest | ||
// if there are no nonces, it leaves an undefined nonce | ||
const nonces = (await Promise.all(txs.map(t => t.nonce))).filter(n => n !== undefined).map(n => ethers.BigNumber.from(n)); | ||
const nonce = nonces.length !== 0 ? nonces.reduce((p, c) => p.lt(c) ? p : c) : undefined; // Maps all transactions into SequenceTransactions | ||
const nonce = nonces.length !== 0 ? nonces.reduce((p, c) => p.lt(c) ? p : c) : undefined; | ||
// Maps all transactions into SequenceTransactions | ||
return Promise.all(allTxs.map(tx => toSequenceTransaction(wallet, tx, revertOnError, gasLimit, nonce))); | ||
@@ -68,7 +66,4 @@ } | ||
const aux = txs.auxiliary; | ||
const tx = _extends({}, txs); | ||
delete tx.auxiliary; | ||
if (aux) { | ||
@@ -83,3 +78,2 @@ return [tx, ...flattenAuxTransactions(aux)]; | ||
} | ||
return txs.flatMap(flattenAuxTransactions); | ||
@@ -91,5 +85,3 @@ } | ||
} | ||
const txGas = tx.gasLimit === undefined ? tx.gas : tx.gasLimit; | ||
if (tx.to) { | ||
@@ -106,3 +98,3 @@ return { | ||
} else { | ||
const walletInterface = new Interface(walletContracts.mainModule.abi); | ||
const walletInterface = new utils.Interface(walletContracts.mainModule.abi); | ||
const data = walletInterface.encodeFunctionData(walletInterface.getFunction('createContract'), [tx.data]); | ||
@@ -132,13 +124,9 @@ const address = typeof wallet === 'string' ? wallet : wallet.getAddress(); | ||
const sample = txs.find(t => t.nonce !== undefined); | ||
if (!sample) { | ||
return undefined; | ||
} | ||
const sampleNonce = ethers.BigNumber.from(sample.nonce); | ||
if (txs.find(t => t.nonce !== undefined && !ethers.BigNumber.from(t.nonce).eq(sampleNonce))) { | ||
throw new Error('Mixed nonces on Sequence transactions'); | ||
} | ||
return sample ? sample.nonce : undefined; | ||
@@ -149,3 +137,2 @@ } | ||
var _t$to; | ||
return { | ||
@@ -167,8 +154,6 @@ delegateCall: t.delegateCall === true, | ||
function makeExpirable(context, txs, expiration) { | ||
const sequenceUtils = new Interface(walletContracts.sequenceUtils.abi); | ||
const sequenceUtils = new utils.Interface(walletContracts.sequenceUtils.abi); | ||
if (!context || !context.sequenceUtils) { | ||
throw new Error('Undefined sequenceUtils'); | ||
} | ||
return [{ | ||
@@ -184,8 +169,6 @@ delegateCall: false, | ||
function makeAfterNonce(context, txs, dep) { | ||
const sequenceUtils = new Interface(walletContracts.sequenceUtils.abi); | ||
const sequenceUtils = new utils.Interface(walletContracts.sequenceUtils.abi); | ||
if (!context || !context.sequenceUtils) { | ||
throw new Error('Undefined sequenceUtils'); | ||
} | ||
return [{ | ||
@@ -204,7 +187,5 @@ delegateCall: false, | ||
const shl = ethers.constants.Two.pow(ethers.BigNumber.from(96)); | ||
if (!bnonce.div(shl).eq(ethers.constants.Zero)) { | ||
throw new Error('Space already encoded'); | ||
} | ||
return bnonce.add(bspace.mul(shl)); | ||
@@ -222,3 +203,2 @@ } | ||
let stx = []; | ||
if (Array.isArray(transaction)) { | ||
@@ -234,12 +214,12 @@ if (hasSequenceTransactions(transaction)) { | ||
stx = await toSequenceTransactions(wallet, [transaction]); | ||
} // If transaction is marked as expirable | ||
} | ||
// If transaction is marked as expirable | ||
// append expirable require | ||
if (transaction.expiration) { | ||
stx = makeExpirable(context, stx, transaction.expiration); | ||
} // If transaction depends on another nonce | ||
} | ||
// If transaction depends on another nonce | ||
// append after nonce requirement | ||
if (transaction.afterNonce) { | ||
@@ -256,3 +236,2 @@ const after = transaction.afterNonce; | ||
} | ||
return stx; | ||
@@ -259,0 +238,0 @@ } |
@@ -1,5 +0,6 @@ | ||
import { BigNumberish, BytesLike } from 'ethers'; | ||
import { TransactionRequest as EthersTransactionRequest, TransactionResponse as EthersTransactionResponse } from '@ethersproject/providers'; | ||
import { BigNumberish, BytesLike, providers } from 'ethers'; | ||
import { DecodedSignature, WalletConfig } from '@0xsequence/config'; | ||
import { WalletContext } from '@0xsequence/network'; | ||
declare type EthersTransactionRequest = providers.TransactionRequest; | ||
declare type EthersTransactionResponse = providers.TransactionResponse; | ||
export interface Transaction { | ||
@@ -45,1 +46,2 @@ to: string; | ||
} | ||
export {}; |
{ | ||
"name": "@0xsequence/transactions", | ||
"version": "0.42.10", | ||
"version": "0.43.0", | ||
"description": "transactions sub-package for Sequence", | ||
@@ -17,10 +17,12 @@ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/transactions", | ||
"dependencies": { | ||
"@0xsequence/abi": "^0.42.10", | ||
"@0xsequence/network": "^0.42.10", | ||
"@0xsequence/utils": "^0.42.10", | ||
"@ethersproject/abi": "^5.5.0", | ||
"ethers": "^5.5.2" | ||
"@0xsequence/abi": "^0.43.0", | ||
"@0xsequence/network": "^0.43.0", | ||
"@0xsequence/utils": "^0.43.0" | ||
}, | ||
"peerDependencies": {}, | ||
"devDependencies": {}, | ||
"peerDependencies": { | ||
"ethers": ">=5.5" | ||
}, | ||
"devDependencies": { | ||
"ethers": "^5.7.2" | ||
}, | ||
"files": [ | ||
@@ -27,0 +29,0 @@ "src", |
@@ -1,6 +0,8 @@ | ||
import { BigNumberish, BytesLike } from 'ethers' | ||
import { TransactionRequest as EthersTransactionRequest, TransactionResponse as EthersTransactionResponse } from '@ethersproject/providers' | ||
import { BigNumberish, BytesLike, providers } from 'ethers' | ||
import { DecodedSignature, WalletConfig } from '@0xsequence/config' | ||
import { WalletContext } from '@0xsequence/network' | ||
type EthersTransactionRequest = providers.TransactionRequest | ||
type EthersTransactionResponse = providers.TransactionResponse | ||
// Transaction is a Sequence transaction payload. Note, we do not include gasPrice as an option in this form, | ||
@@ -7,0 +9,0 @@ // as we expect the gasPrice to be optimally estimated by the transaction relayer. |
@@ -1,3 +0,2 @@ | ||
import { ethers, Signer, BigNumberish } from 'ethers' | ||
import { Interface } from '@ethersproject/abi' | ||
import { ethers, Signer, BigNumberish, utils } from 'ethers' | ||
import { walletContracts } from '@0xsequence/abi' | ||
@@ -104,3 +103,3 @@ import { WalletContext } from '@0xsequence/network' | ||
} else { | ||
const walletInterface = new Interface(walletContracts.mainModule.abi) | ||
const walletInterface = new utils.Interface(walletContracts.mainModule.abi) | ||
const data = walletInterface.encodeFunctionData(walletInterface.getFunction('createContract'), [tx.data]) | ||
@@ -163,3 +162,3 @@ const address = typeof wallet === 'string' ? wallet : wallet.getAddress() | ||
export function makeExpirable(context: WalletContext, txs: Transaction[], expiration: BigNumberish): Transaction[] { | ||
const sequenceUtils = new Interface(walletContracts.sequenceUtils.abi) | ||
const sequenceUtils = new utils.Interface(walletContracts.sequenceUtils.abi) | ||
@@ -184,3 +183,3 @@ if (!context || !context.sequenceUtils) { | ||
export function makeAfterNonce(context: WalletContext, txs: Transaction[], dep: NonceDependency): Transaction[] { | ||
const sequenceUtils = new Interface(walletContracts.sequenceUtils.abi) | ||
const sequenceUtils = new utils.Interface(walletContracts.sequenceUtils.abi) | ||
@@ -187,0 +186,0 @@ if (!context || !context.sequenceUtils) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4
1069
42880
1
+ Added@0xsequence/abi@0.43.34(transitive)
+ Added@0xsequence/api@0.43.34(transitive)
+ Added@0xsequence/auth@0.43.34(transitive)
+ Added@0xsequence/config@0.43.34(transitive)
+ Added@0xsequence/ethauth@0.8.1(transitive)
+ Added@0xsequence/guard@0.43.34(transitive)
+ Added@0xsequence/indexer@0.43.34(transitive)
+ Added@0xsequence/metadata@0.43.34(transitive)
+ Added@0xsequence/multicall@0.43.34(transitive)
+ Added@0xsequence/network@0.43.34(transitive)
+ Added@0xsequence/provider@0.43.34(transitive)
+ Added@0xsequence/relayer@0.43.34(transitive)
+ Added@0xsequence/transactions@0.43.34(transitive)
+ Added@0xsequence/utils@0.43.34(transitive)
+ Added@0xsequence/wallet@0.43.34(transitive)
+ Added@adraffy/ens-normalize@1.10.1(transitive)
+ Added@noble/curves@1.2.0(transitive)
+ Added@noble/hashes@1.3.2(transitive)
+ Added@types/node@22.7.5(transitive)
+ Addedaes-js@4.0.0-beta.5(transitive)
+ Addedethers@6.13.4(transitive)
+ Addedeventemitter2@6.4.9(transitive)
+ Addedtslib@2.7.0(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addedwebextension-polyfill@0.10.0(transitive)
+ Addedws@8.17.1(transitive)
- Removed@ethersproject/abi@^5.5.0
- Removedethers@^5.5.2
- Removed@0xsequence/abi@0.42.10(transitive)
- Removed@0xsequence/network@0.42.10(transitive)
- Removed@0xsequence/utils@0.42.10(transitive)
Updated@0xsequence/abi@^0.43.0
Updated@0xsequence/network@^0.43.0
Updated@0xsequence/utils@^0.43.0