Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@depay/web3-payments

Package Overview
Dependencies
Maintainers
1
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@depay/web3-payments - npm Package Compare versions

Comparing version 10.10.2 to 11.0.0

81

dist/esm/index.evm.js

@@ -28,23 +28,2 @@ import { CONSTANTS } from '@depay/web3-constants';

const prepareContractCallAddressAmountBooleanTransaction = (transaction, toContract)=> {
transaction.params.data = [
toContract.signature,
toContract.params[0]
];
return transaction
};
const prepareContractCallAddressPassedAmountBooleanTransaction = (transaction, toContract)=> {
transaction.params.data = [
toContract.signature,
toContract.params[1]
];
if(!transaction.params.amounts[1]) { transaction.params.amounts[1] = '0'; }
if(!transaction.params.amounts[2]) { transaction.params.amounts[2] = '0'; }
if(!transaction.params.amounts[3]) { transaction.params.amounts[3] = '0'; }
if(!transaction.params.amounts[4]) { transaction.params.amounts[4] = '0'; }
transaction.params.amounts[5] = toContract.params[0];
return transaction
};
var plugins = {

@@ -66,12 +45,2 @@ ethereum: {

},
contractCall: {
approveAndCallContractAddressAmountBoolean: {
address: '0xF984eb8b466AD6c728E0aCc7b69Af6f69B32437F',
prepareTransaction: prepareContractCallAddressAmountBooleanTransaction
},
approveAndCallContractAddressPassedAmountBoolean: {
address: '0x2D18c5A46cc1780d2460DD51B5d0996e55Fd2446',
prepareTransaction: prepareContractCallAddressPassedAmountBooleanTransaction
}
},
paymentFee: {

@@ -99,12 +68,2 @@ address: '0x874Cb669D7BFff79d4A6A30F4ea52c5e413BD6A7',

},
contractCall: {
approveAndCallContractAddressAmountBoolean: {
address: '0xd73dFeF8F9c213b449fB39B84c2b33FBBc2C8eD3',
prepareTransaction: prepareContractCallAddressAmountBooleanTransaction
},
approveAndCallContractAddressPassedAmountBoolean: {
address: '0x7E655088214d0657251A51aDccE9109CFd23B5B5',
prepareTransaction: prepareContractCallAddressPassedAmountBooleanTransaction
}
},
paymentFee: {

@@ -132,12 +91,2 @@ address: '0xae33f10AD57A38113f74FCdc1ffA6B1eC47B94E3',

},
contractCall: {
approveAndCallContractAddressAmountBoolean: {
address: '0x8698E529E9867eEbcC68b4792daC627cd8870736',
prepareTransaction: prepareContractCallAddressAmountBooleanTransaction
},
approveAndCallContractAddressPassedAmountBoolean: {
address: '0xAB305eaDf5FB15AF6370106B231C67d103bBbbbC',
prepareTransaction: prepareContractCallAddressPassedAmountBooleanTransaction
}
},
paymentFee: {

@@ -167,3 +116,2 @@ address: '0xd625c7087E940b2A91ed8bD8db45cB24D3526B56',

function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
let getTransaction = async({ paymentRoute, event, fee })=> {

@@ -187,6 +135,2 @@ let exchangeRoute = paymentRoute.exchangeRoutes[0];

if(paymentRoute.contractCallPlugin) {
transaction = paymentRoute.contractCallPlugin.prepareTransaction(transaction, paymentRoute.toContract);
}
return transaction

@@ -330,17 +274,3 @@ };

if(paymentRoute.toContract) {
let signature = paymentRoute.toContract.signature.match(/\(.*\)/);
if(signature && _optionalChain$1([signature, 'optionalAccess', _ => _.length])) {
signature = signature[0].replace(/[\(\)]/g, '');
let splitSignature = signature.split(',');
if(splitSignature[0] == 'address' && splitSignature[1].match('uint') && splitSignature[2] == 'bool' && Number.isNaN(parseInt(paymentRoute.toContract.params[0]))) {
paymentRoute.contractCallPlugin = plugins[paymentRoute.blockchain].contractCall.approveAndCallContractAddressAmountBoolean;
} else if(splitSignature[0] == 'address' && splitSignature[1].match('uint') && splitSignature[2] == 'bool' && !Number.isNaN(parseInt(paymentRoute.toContract.params[0]))) {
paymentRoute.contractCallPlugin = plugins[paymentRoute.blockchain].contractCall.approveAndCallContractAddressPassedAmountBoolean;
} else {
throw(signature)
}
paymentPlugins.push(paymentRoute.contractCallPlugin.address);
}
} else if(event == 'ifSwapped' && !paymentRoute.directTransfer) {
if(event == 'ifSwapped' && !paymentRoute.directTransfer) {
paymentPlugins.push(plugins[paymentRoute.blockchain].paymentWithEvent.address);

@@ -957,3 +887,3 @@ } else if(event == 'ifRoutedAndNative' && !paymentRoute.directTransfer && paymentRoute.toToken.address == CONSTANTS[paymentRoute.blockchain].NATIVE) {

class PaymentRoute {
constructor({ blockchain, fromAddress, fromToken, fromDecimals, fromAmount, fromBalance, toToken, toDecimals, toAmount, toAddress, toContract }) {
constructor({ blockchain, fromAddress, fromToken, fromDecimals, fromAmount, fromBalance, toToken, toDecimals, toAmount, toAddress }) {
this.blockchain = blockchain;

@@ -969,3 +899,2 @@ this.fromAddress = fromAddress;

this.toAddress = toAddress;
this.toContract = toContract;
this.exchangeRoutes = [];

@@ -1001,3 +930,2 @@ this.transaction = undefined;

toAddress: configuration.toAddress,
toContract: configuration.toContract
})

@@ -1021,3 +949,2 @@ } else if(configuration.fromToken && configuration.fromAmount && fromToken.address.toLowerCase() == configuration.fromToken.toLowerCase()) {

toAddress: configuration.toAddress,
toContract: configuration.toContract
})

@@ -1176,3 +1103,3 @@ }

route.fromToken.address.toLowerCase() == CONSTANTS[route.blockchain].NATIVE.toLowerCase()
) && route.toContract == undefined
)
) {

@@ -1200,3 +1127,3 @@ routes[index].approvalRequired = false;

return routes.map((route)=>{
route.directTransfer = route.fromToken.address.toLowerCase() == route.toToken.address.toLowerCase() && route.toContract == undefined && fee == undefined;
route.directTransfer = route.fromToken.address.toLowerCase() == route.toToken.address.toLowerCase() && fee == undefined;
return route

@@ -1203,0 +1130,0 @@ })

@@ -28,23 +28,2 @@ import { CONSTANTS } from '@depay/web3-constants';

const prepareContractCallAddressAmountBooleanTransaction = (transaction, toContract)=> {
transaction.params.data = [
toContract.signature,
toContract.params[0]
];
return transaction
};
const prepareContractCallAddressPassedAmountBooleanTransaction = (transaction, toContract)=> {
transaction.params.data = [
toContract.signature,
toContract.params[1]
];
if(!transaction.params.amounts[1]) { transaction.params.amounts[1] = '0'; }
if(!transaction.params.amounts[2]) { transaction.params.amounts[2] = '0'; }
if(!transaction.params.amounts[3]) { transaction.params.amounts[3] = '0'; }
if(!transaction.params.amounts[4]) { transaction.params.amounts[4] = '0'; }
transaction.params.amounts[5] = toContract.params[0];
return transaction
};
var plugins = {

@@ -66,12 +45,2 @@ ethereum: {

},
contractCall: {
approveAndCallContractAddressAmountBoolean: {
address: '0xF984eb8b466AD6c728E0aCc7b69Af6f69B32437F',
prepareTransaction: prepareContractCallAddressAmountBooleanTransaction
},
approveAndCallContractAddressPassedAmountBoolean: {
address: '0x2D18c5A46cc1780d2460DD51B5d0996e55Fd2446',
prepareTransaction: prepareContractCallAddressPassedAmountBooleanTransaction
}
},
paymentFee: {

@@ -99,12 +68,2 @@ address: '0x874Cb669D7BFff79d4A6A30F4ea52c5e413BD6A7',

},
contractCall: {
approveAndCallContractAddressAmountBoolean: {
address: '0xd73dFeF8F9c213b449fB39B84c2b33FBBc2C8eD3',
prepareTransaction: prepareContractCallAddressAmountBooleanTransaction
},
approveAndCallContractAddressPassedAmountBoolean: {
address: '0x7E655088214d0657251A51aDccE9109CFd23B5B5',
prepareTransaction: prepareContractCallAddressPassedAmountBooleanTransaction
}
},
paymentFee: {

@@ -132,12 +91,2 @@ address: '0xae33f10AD57A38113f74FCdc1ffA6B1eC47B94E3',

},
contractCall: {
approveAndCallContractAddressAmountBoolean: {
address: '0x8698E529E9867eEbcC68b4792daC627cd8870736',
prepareTransaction: prepareContractCallAddressAmountBooleanTransaction
},
approveAndCallContractAddressPassedAmountBoolean: {
address: '0xAB305eaDf5FB15AF6370106B231C67d103bBbbbC',
prepareTransaction: prepareContractCallAddressPassedAmountBooleanTransaction
}
},
paymentFee: {

@@ -167,3 +116,2 @@ address: '0xd625c7087E940b2A91ed8bD8db45cB24D3526B56',

function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
let getTransaction = async({ paymentRoute, event, fee })=> {

@@ -187,6 +135,2 @@ let exchangeRoute = paymentRoute.exchangeRoutes[0];

if(paymentRoute.contractCallPlugin) {
transaction = paymentRoute.contractCallPlugin.prepareTransaction(transaction, paymentRoute.toContract);
}
return transaction

@@ -330,17 +274,3 @@ };

if(paymentRoute.toContract) {
let signature = paymentRoute.toContract.signature.match(/\(.*\)/);
if(signature && _optionalChain$1([signature, 'optionalAccess', _ => _.length])) {
signature = signature[0].replace(/[\(\)]/g, '');
let splitSignature = signature.split(',');
if(splitSignature[0] == 'address' && splitSignature[1].match('uint') && splitSignature[2] == 'bool' && Number.isNaN(parseInt(paymentRoute.toContract.params[0]))) {
paymentRoute.contractCallPlugin = plugins[paymentRoute.blockchain].contractCall.approveAndCallContractAddressAmountBoolean;
} else if(splitSignature[0] == 'address' && splitSignature[1].match('uint') && splitSignature[2] == 'bool' && !Number.isNaN(parseInt(paymentRoute.toContract.params[0]))) {
paymentRoute.contractCallPlugin = plugins[paymentRoute.blockchain].contractCall.approveAndCallContractAddressPassedAmountBoolean;
} else {
throw(signature)
}
paymentPlugins.push(paymentRoute.contractCallPlugin.address);
}
} else if(event == 'ifSwapped' && !paymentRoute.directTransfer) {
if(event == 'ifSwapped' && !paymentRoute.directTransfer) {
paymentPlugins.push(plugins[paymentRoute.blockchain].paymentWithEvent.address);

@@ -957,3 +887,3 @@ } else if(event == 'ifRoutedAndNative' && !paymentRoute.directTransfer && paymentRoute.toToken.address == CONSTANTS[paymentRoute.blockchain].NATIVE) {

class PaymentRoute {
constructor({ blockchain, fromAddress, fromToken, fromDecimals, fromAmount, fromBalance, toToken, toDecimals, toAmount, toAddress, toContract }) {
constructor({ blockchain, fromAddress, fromToken, fromDecimals, fromAmount, fromBalance, toToken, toDecimals, toAmount, toAddress }) {
this.blockchain = blockchain;

@@ -969,3 +899,2 @@ this.fromAddress = fromAddress;

this.toAddress = toAddress;
this.toContract = toContract;
this.exchangeRoutes = [];

@@ -1001,3 +930,2 @@ this.transaction = undefined;

toAddress: configuration.toAddress,
toContract: configuration.toContract
})

@@ -1021,3 +949,2 @@ } else if(configuration.fromToken && configuration.fromAmount && fromToken.address.toLowerCase() == configuration.fromToken.toLowerCase()) {

toAddress: configuration.toAddress,
toContract: configuration.toContract
})

@@ -1176,3 +1103,3 @@ }

route.fromToken.address.toLowerCase() == CONSTANTS[route.blockchain].NATIVE.toLowerCase()
) && route.toContract == undefined
)
) {

@@ -1200,3 +1127,3 @@ routes[index].approvalRequired = false;

return routes.map((route)=>{
route.directTransfer = route.fromToken.address.toLowerCase() == route.toToken.address.toLowerCase() && route.toContract == undefined && fee == undefined;
route.directTransfer = route.fromToken.address.toLowerCase() == route.toToken.address.toLowerCase() && fee == undefined;
return route

@@ -1203,0 +1130,0 @@ })

@@ -28,23 +28,2 @@ (function (global, factory) {

const prepareContractCallAddressAmountBooleanTransaction = (transaction, toContract)=> {
transaction.params.data = [
toContract.signature,
toContract.params[0]
];
return transaction
};
const prepareContractCallAddressPassedAmountBooleanTransaction = (transaction, toContract)=> {
transaction.params.data = [
toContract.signature,
toContract.params[1]
];
if(!transaction.params.amounts[1]) { transaction.params.amounts[1] = '0'; }
if(!transaction.params.amounts[2]) { transaction.params.amounts[2] = '0'; }
if(!transaction.params.amounts[3]) { transaction.params.amounts[3] = '0'; }
if(!transaction.params.amounts[4]) { transaction.params.amounts[4] = '0'; }
transaction.params.amounts[5] = toContract.params[0];
return transaction
};
var plugins = {

@@ -66,12 +45,2 @@ ethereum: {

},
contractCall: {
approveAndCallContractAddressAmountBoolean: {
address: '0xF984eb8b466AD6c728E0aCc7b69Af6f69B32437F',
prepareTransaction: prepareContractCallAddressAmountBooleanTransaction
},
approveAndCallContractAddressPassedAmountBoolean: {
address: '0x2D18c5A46cc1780d2460DD51B5d0996e55Fd2446',
prepareTransaction: prepareContractCallAddressPassedAmountBooleanTransaction
}
},
paymentFee: {

@@ -99,12 +68,2 @@ address: '0x874Cb669D7BFff79d4A6A30F4ea52c5e413BD6A7',

},
contractCall: {
approveAndCallContractAddressAmountBoolean: {
address: '0xd73dFeF8F9c213b449fB39B84c2b33FBBc2C8eD3',
prepareTransaction: prepareContractCallAddressAmountBooleanTransaction
},
approveAndCallContractAddressPassedAmountBoolean: {
address: '0x7E655088214d0657251A51aDccE9109CFd23B5B5',
prepareTransaction: prepareContractCallAddressPassedAmountBooleanTransaction
}
},
paymentFee: {

@@ -132,12 +91,2 @@ address: '0xae33f10AD57A38113f74FCdc1ffA6B1eC47B94E3',

},
contractCall: {
approveAndCallContractAddressAmountBoolean: {
address: '0x8698E529E9867eEbcC68b4792daC627cd8870736',
prepareTransaction: prepareContractCallAddressAmountBooleanTransaction
},
approveAndCallContractAddressPassedAmountBoolean: {
address: '0xAB305eaDf5FB15AF6370106B231C67d103bBbbbC',
prepareTransaction: prepareContractCallAddressPassedAmountBooleanTransaction
}
},
paymentFee: {

@@ -167,3 +116,2 @@ address: '0xd625c7087E940b2A91ed8bD8db45cB24D3526B56',

function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
let getTransaction = async({ paymentRoute, event, fee })=> {

@@ -187,6 +135,2 @@ let exchangeRoute = paymentRoute.exchangeRoutes[0];

if(paymentRoute.contractCallPlugin) {
transaction = paymentRoute.contractCallPlugin.prepareTransaction(transaction, paymentRoute.toContract);
}
return transaction

@@ -330,17 +274,3 @@ };

if(paymentRoute.toContract) {
let signature = paymentRoute.toContract.signature.match(/\(.*\)/);
if(signature && _optionalChain$1([signature, 'optionalAccess', _ => _.length])) {
signature = signature[0].replace(/[\(\)]/g, '');
let splitSignature = signature.split(',');
if(splitSignature[0] == 'address' && splitSignature[1].match('uint') && splitSignature[2] == 'bool' && Number.isNaN(parseInt(paymentRoute.toContract.params[0]))) {
paymentRoute.contractCallPlugin = plugins[paymentRoute.blockchain].contractCall.approveAndCallContractAddressAmountBoolean;
} else if(splitSignature[0] == 'address' && splitSignature[1].match('uint') && splitSignature[2] == 'bool' && !Number.isNaN(parseInt(paymentRoute.toContract.params[0]))) {
paymentRoute.contractCallPlugin = plugins[paymentRoute.blockchain].contractCall.approveAndCallContractAddressPassedAmountBoolean;
} else {
throw(signature)
}
paymentPlugins.push(paymentRoute.contractCallPlugin.address);
}
} else if(event == 'ifSwapped' && !paymentRoute.directTransfer) {
if(event == 'ifSwapped' && !paymentRoute.directTransfer) {
paymentPlugins.push(plugins[paymentRoute.blockchain].paymentWithEvent.address);

@@ -957,3 +887,3 @@ } else if(event == 'ifRoutedAndNative' && !paymentRoute.directTransfer && paymentRoute.toToken.address == web3Constants.CONSTANTS[paymentRoute.blockchain].NATIVE) {

class PaymentRoute {
constructor({ blockchain, fromAddress, fromToken, fromDecimals, fromAmount, fromBalance, toToken, toDecimals, toAmount, toAddress, toContract }) {
constructor({ blockchain, fromAddress, fromToken, fromDecimals, fromAmount, fromBalance, toToken, toDecimals, toAmount, toAddress }) {
this.blockchain = blockchain;

@@ -969,3 +899,2 @@ this.fromAddress = fromAddress;

this.toAddress = toAddress;
this.toContract = toContract;
this.exchangeRoutes = [];

@@ -1001,3 +930,2 @@ this.transaction = undefined;

toAddress: configuration.toAddress,
toContract: configuration.toContract
})

@@ -1021,3 +949,2 @@ } else if(configuration.fromToken && configuration.fromAmount && fromToken.address.toLowerCase() == configuration.fromToken.toLowerCase()) {

toAddress: configuration.toAddress,
toContract: configuration.toContract
})

@@ -1176,3 +1103,3 @@ }

route.fromToken.address.toLowerCase() == web3Constants.CONSTANTS[route.blockchain].NATIVE.toLowerCase()
) && route.toContract == undefined
)
) {

@@ -1200,3 +1127,3 @@ routes[index].approvalRequired = false;

return routes.map((route)=>{
route.directTransfer = route.fromToken.address.toLowerCase() == route.toToken.address.toLowerCase() && route.toContract == undefined && fee == undefined;
route.directTransfer = route.fromToken.address.toLowerCase() == route.toToken.address.toLowerCase() && fee == undefined;
return route

@@ -1203,0 +1130,0 @@ })

@@ -28,23 +28,2 @@ (function (global, factory) {

const prepareContractCallAddressAmountBooleanTransaction = (transaction, toContract)=> {
transaction.params.data = [
toContract.signature,
toContract.params[0]
];
return transaction
};
const prepareContractCallAddressPassedAmountBooleanTransaction = (transaction, toContract)=> {
transaction.params.data = [
toContract.signature,
toContract.params[1]
];
if(!transaction.params.amounts[1]) { transaction.params.amounts[1] = '0'; }
if(!transaction.params.amounts[2]) { transaction.params.amounts[2] = '0'; }
if(!transaction.params.amounts[3]) { transaction.params.amounts[3] = '0'; }
if(!transaction.params.amounts[4]) { transaction.params.amounts[4] = '0'; }
transaction.params.amounts[5] = toContract.params[0];
return transaction
};
var plugins = {

@@ -66,12 +45,2 @@ ethereum: {

},
contractCall: {
approveAndCallContractAddressAmountBoolean: {
address: '0xF984eb8b466AD6c728E0aCc7b69Af6f69B32437F',
prepareTransaction: prepareContractCallAddressAmountBooleanTransaction
},
approveAndCallContractAddressPassedAmountBoolean: {
address: '0x2D18c5A46cc1780d2460DD51B5d0996e55Fd2446',
prepareTransaction: prepareContractCallAddressPassedAmountBooleanTransaction
}
},
paymentFee: {

@@ -99,12 +68,2 @@ address: '0x874Cb669D7BFff79d4A6A30F4ea52c5e413BD6A7',

},
contractCall: {
approveAndCallContractAddressAmountBoolean: {
address: '0xd73dFeF8F9c213b449fB39B84c2b33FBBc2C8eD3',
prepareTransaction: prepareContractCallAddressAmountBooleanTransaction
},
approveAndCallContractAddressPassedAmountBoolean: {
address: '0x7E655088214d0657251A51aDccE9109CFd23B5B5',
prepareTransaction: prepareContractCallAddressPassedAmountBooleanTransaction
}
},
paymentFee: {

@@ -132,12 +91,2 @@ address: '0xae33f10AD57A38113f74FCdc1ffA6B1eC47B94E3',

},
contractCall: {
approveAndCallContractAddressAmountBoolean: {
address: '0x8698E529E9867eEbcC68b4792daC627cd8870736',
prepareTransaction: prepareContractCallAddressAmountBooleanTransaction
},
approveAndCallContractAddressPassedAmountBoolean: {
address: '0xAB305eaDf5FB15AF6370106B231C67d103bBbbbC',
prepareTransaction: prepareContractCallAddressPassedAmountBooleanTransaction
}
},
paymentFee: {

@@ -167,3 +116,2 @@ address: '0xd625c7087E940b2A91ed8bD8db45cB24D3526B56',

function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
let getTransaction = async({ paymentRoute, event, fee })=> {

@@ -187,6 +135,2 @@ let exchangeRoute = paymentRoute.exchangeRoutes[0];

if(paymentRoute.contractCallPlugin) {
transaction = paymentRoute.contractCallPlugin.prepareTransaction(transaction, paymentRoute.toContract);
}
return transaction

@@ -330,17 +274,3 @@ };

if(paymentRoute.toContract) {
let signature = paymentRoute.toContract.signature.match(/\(.*\)/);
if(signature && _optionalChain$1([signature, 'optionalAccess', _ => _.length])) {
signature = signature[0].replace(/[\(\)]/g, '');
let splitSignature = signature.split(',');
if(splitSignature[0] == 'address' && splitSignature[1].match('uint') && splitSignature[2] == 'bool' && Number.isNaN(parseInt(paymentRoute.toContract.params[0]))) {
paymentRoute.contractCallPlugin = plugins[paymentRoute.blockchain].contractCall.approveAndCallContractAddressAmountBoolean;
} else if(splitSignature[0] == 'address' && splitSignature[1].match('uint') && splitSignature[2] == 'bool' && !Number.isNaN(parseInt(paymentRoute.toContract.params[0]))) {
paymentRoute.contractCallPlugin = plugins[paymentRoute.blockchain].contractCall.approveAndCallContractAddressPassedAmountBoolean;
} else {
throw(signature)
}
paymentPlugins.push(paymentRoute.contractCallPlugin.address);
}
} else if(event == 'ifSwapped' && !paymentRoute.directTransfer) {
if(event == 'ifSwapped' && !paymentRoute.directTransfer) {
paymentPlugins.push(plugins[paymentRoute.blockchain].paymentWithEvent.address);

@@ -957,3 +887,3 @@ } else if(event == 'ifRoutedAndNative' && !paymentRoute.directTransfer && paymentRoute.toToken.address == web3Constants.CONSTANTS[paymentRoute.blockchain].NATIVE) {

class PaymentRoute {
constructor({ blockchain, fromAddress, fromToken, fromDecimals, fromAmount, fromBalance, toToken, toDecimals, toAmount, toAddress, toContract }) {
constructor({ blockchain, fromAddress, fromToken, fromDecimals, fromAmount, fromBalance, toToken, toDecimals, toAmount, toAddress }) {
this.blockchain = blockchain;

@@ -969,3 +899,2 @@ this.fromAddress = fromAddress;

this.toAddress = toAddress;
this.toContract = toContract;
this.exchangeRoutes = [];

@@ -1001,3 +930,2 @@ this.transaction = undefined;

toAddress: configuration.toAddress,
toContract: configuration.toContract
})

@@ -1021,3 +949,2 @@ } else if(configuration.fromToken && configuration.fromAmount && fromToken.address.toLowerCase() == configuration.fromToken.toLowerCase()) {

toAddress: configuration.toAddress,
toContract: configuration.toContract
})

@@ -1176,3 +1103,3 @@ }

route.fromToken.address.toLowerCase() == web3Constants.CONSTANTS[route.blockchain].NATIVE.toLowerCase()
) && route.toContract == undefined
)
) {

@@ -1200,3 +1127,3 @@ routes[index].approvalRequired = false;

return routes.map((route)=>{
route.directTransfer = route.fromToken.address.toLowerCase() == route.toToken.address.toLowerCase() && route.toContract == undefined && fee == undefined;
route.directTransfer = route.fromToken.address.toLowerCase() == route.toToken.address.toLowerCase() && fee == undefined;
return route

@@ -1203,0 +1130,0 @@ })

2

package.json
{
"name": "@depay/web3-payments",
"moduleName": "Web3Payments",
"version": "10.10.2",
"version": "11.0.0",
"description": "JavaScript library to scan crypto wallets for liquefiable assets and calculate most cost-effective payment routing.",

@@ -6,0 +6,0 @@ "main": "dist/umd/index.js",

@@ -166,81 +166,2 @@ ## Quickstart

#### Pay into Smart Contracts
In case you want to pay into smart contract (calling a smart contract method), you will need to pass `toContract` in addition to `toAddress`:
```javascript
import { route } from '@depay/web3-payments'
let paymentRoutes = await route({
accept: [
{
blockchain: 'ethereum',
token: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb',
amount: 20,
toAddress: '0xb0252f13850a4823706607524de0b146820F2240',
toContract: {
signature: 'claim(address,uint256,bool)',
params: ['true']
}
}
],
from: { bsc: '0x5Af489c8786A018EC4814194dC8048be1007e390' }
})
```
To contract needs to contain at lest the `signature` field. Depending on the `signature` field `params` also need to be provided.
The previous example after swapping payment tokens, will call the contract at `0xb0252f13850a4823706607524de0b146820F2240` calling method `claim` passing `address` from the payment sender
and amounts from the final token amounts also forwarding `params[0]` to pass the value for `bool`.
If you want to know more about paying into smart contracts, checkout the [depay-evm-router](https://github.com/depayfi/depay-evm-router).
Read following the currently supported contract call signatures:
##### signature(address,uint256,bool)
###### While inferring uint256 from paid amount:
```javascript
import { route } from '@depay/web3-payments'
let paymentRoutes = await route({
accept: [
{
blockchain: 'ethereum',
token: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb',
amount: 20,
toAddress: '0xb0252f13850a4823706607524de0b146820F2240',
toContract: {
signature: 'claim(address,uint256,bool)',
params: ['true']
}
}
],
from: { bsc: '0x5Af489c8786A018EC4814194dC8048be1007e390' }
})
```
###### Passing uint256 explicitly:
```javascript
import { route } from '@depay/web3-payments'
let paymentRoutes = await route({
accept: [
{
blockchain: 'ethereum',
token: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb',
amount: 20,
toAddress: '0xb0252f13850a4823706607524de0b146820F2240',
toContract: {
signature: 'claim(address,uint256,bool)',
params: ['40000000000000000000', 'true']
}
}
],
from: { bsc: '0x5Af489c8786A018EC4814194dC8048be1007e390' }
})
```
#### whitelist

@@ -247,0 +168,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc