Skip to content

Commit

Permalink
v13.12.7: fix transaction.deadline = for EVM and World Chain
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNe0x1 committed Oct 14, 2024
1 parent d175614 commit a6640d3
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 43 deletions.
19 changes: 11 additions & 8 deletions dist/esm/index.evm.js
Original file line number Diff line number Diff line change
Expand Up @@ -51036,15 +51036,24 @@ const EXCHANGE_PROXIES = {

const getTransaction$2 = async({ paymentRoute, options })=> {

let deadline;
if(paymentRoute.blockchain === 'worldchain'){ // protocol V3 deadline
deadline = Math.ceil(new Date())+3600*1000; // 1 hour in ms
} else {
deadline = Math.ceil(new Date()/1000)+3600; // 1 hour in s
}

const transaction = {
blockchain: paymentRoute.blockchain,
to: transactionAddress({ paymentRoute, options }),
api: transactionApi({ paymentRoute, options }),
method: transactionMethod({ paymentRoute, options }),
params: await transactionParams({ paymentRoute, options }),
params: await transactionParams({ paymentRoute, options, deadline }),
value: transactionValue({ paymentRoute })
};

transaction.deadline = deadline;

return transaction
};

Expand Down Expand Up @@ -51167,20 +51176,14 @@ const getPermit2SignatureTransferNonce = async({ address, blockchain })=>{
}
};

const transactionParams = async ({ paymentRoute, options })=> {
const transactionParams = async ({ paymentRoute, options, deadline })=> {
if(paymentRoute.directTransfer && !paymentRoute.fee && _optionalChain$1([options, 'optionalAccess', _7 => _7.wallet, 'optionalAccess', _8 => _8.name]) !== 'World App') {
if(paymentRoute.toToken.address == Blockchains[paymentRoute.blockchain].currency.address) {
return undefined
} else { // standard token transfer
return [paymentRoute.toAddress, paymentRoute.toAmount]
}
} else {
let deadline;
if(paymentRoute.blockchain === 'worldchain'){ // protocol V3 deadline
deadline = Math.ceil(new Date())+3600*1000; // 1 hour in ms
} else {
deadline = Math.ceil(new Date()/1000)+3600; // 1 hour in s
}
const exchangeRoute = paymentRoute.exchangeRoutes[0];
const exchangeType = getExchangeType({ exchangeRoute, blockchain: paymentRoute.blockchain });
const exchangeTransaction = !exchangeRoute ? undefined : await exchangeRoute.getTransaction({
Expand Down
19 changes: 11 additions & 8 deletions dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2085,15 +2085,24 @@ const EXCHANGE_PROXIES = {

const getTransaction$2 = async({ paymentRoute, options })=> {

let deadline;
if(paymentRoute.blockchain === 'worldchain'){ // protocol V3 deadline
deadline = Math.ceil(new Date())+3600*1000; // 1 hour in ms
} else {
deadline = Math.ceil(new Date()/1000)+3600; // 1 hour in s
}

const transaction = {
blockchain: paymentRoute.blockchain,
to: transactionAddress({ paymentRoute, options }),
api: transactionApi({ paymentRoute, options }),
method: transactionMethod({ paymentRoute, options }),
params: await transactionParams({ paymentRoute, options }),
params: await transactionParams({ paymentRoute, options, deadline }),
value: transactionValue({ paymentRoute })
};

transaction.deadline = deadline;

return transaction
};

Expand Down Expand Up @@ -2216,20 +2225,14 @@ const getPermit2SignatureTransferNonce = async({ address, blockchain })=>{
}
};

const transactionParams = async ({ paymentRoute, options })=> {
const transactionParams = async ({ paymentRoute, options, deadline })=> {
if(paymentRoute.directTransfer && !paymentRoute.fee && _optionalChain$1([options, 'optionalAccess', _7 => _7.wallet, 'optionalAccess', _8 => _8.name]) !== 'World App') {
if(paymentRoute.toToken.address == Blockchains[paymentRoute.blockchain].currency.address) {
return undefined
} else { // standard token transfer
return [paymentRoute.toAddress, paymentRoute.toAmount]
}
} else {
let deadline;
if(paymentRoute.blockchain === 'worldchain'){ // protocol V3 deadline
deadline = Math.ceil(new Date())+3600*1000; // 1 hour in ms
} else {
deadline = Math.ceil(new Date()/1000)+3600; // 1 hour in s
}
const exchangeRoute = paymentRoute.exchangeRoutes[0];
const exchangeType = getExchangeType({ exchangeRoute, blockchain: paymentRoute.blockchain });
const exchangeTransaction = !exchangeRoute ? undefined : await exchangeRoute.getTransaction({
Expand Down
19 changes: 11 additions & 8 deletions dist/umd/index.evm.js
Original file line number Diff line number Diff line change
Expand Up @@ -51042,15 +51042,24 @@

const getTransaction$2 = async({ paymentRoute, options })=> {

let deadline;
if(paymentRoute.blockchain === 'worldchain'){ // protocol V3 deadline
deadline = Math.ceil(new Date())+3600*1000; // 1 hour in ms
} else {
deadline = Math.ceil(new Date()/1000)+3600; // 1 hour in s
}

const transaction = {
blockchain: paymentRoute.blockchain,
to: transactionAddress({ paymentRoute, options }),
api: transactionApi({ paymentRoute, options }),
method: transactionMethod({ paymentRoute, options }),
params: await transactionParams({ paymentRoute, options }),
params: await transactionParams({ paymentRoute, options, deadline }),
value: transactionValue({ paymentRoute })
};

transaction.deadline = deadline;

return transaction
};

Expand Down Expand Up @@ -51173,20 +51182,14 @@
}
};

const transactionParams = async ({ paymentRoute, options })=> {
const transactionParams = async ({ paymentRoute, options, deadline })=> {
if(paymentRoute.directTransfer && !paymentRoute.fee && _optionalChain$1([options, 'optionalAccess', _7 => _7.wallet, 'optionalAccess', _8 => _8.name]) !== 'World App') {
if(paymentRoute.toToken.address == Blockchains__default["default"][paymentRoute.blockchain].currency.address) {
return undefined
} else { // standard token transfer
return [paymentRoute.toAddress, paymentRoute.toAmount]
}
} else {
let deadline;
if(paymentRoute.blockchain === 'worldchain'){ // protocol V3 deadline
deadline = Math.ceil(new Date())+3600*1000; // 1 hour in ms
} else {
deadline = Math.ceil(new Date()/1000)+3600; // 1 hour in s
}
const exchangeRoute = paymentRoute.exchangeRoutes[0];
const exchangeType = getExchangeType({ exchangeRoute, blockchain: paymentRoute.blockchain });
const exchangeTransaction = !exchangeRoute ? undefined : await exchangeRoute.getTransaction({
Expand Down
19 changes: 11 additions & 8 deletions dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2090,15 +2090,24 @@

const getTransaction$2 = async({ paymentRoute, options })=> {

let deadline;
if(paymentRoute.blockchain === 'worldchain'){ // protocol V3 deadline
deadline = Math.ceil(new Date())+3600*1000; // 1 hour in ms
} else {
deadline = Math.ceil(new Date()/1000)+3600; // 1 hour in s
}

const transaction = {
blockchain: paymentRoute.blockchain,
to: transactionAddress({ paymentRoute, options }),
api: transactionApi({ paymentRoute, options }),
method: transactionMethod({ paymentRoute, options }),
params: await transactionParams({ paymentRoute, options }),
params: await transactionParams({ paymentRoute, options, deadline }),
value: transactionValue({ paymentRoute })
};

transaction.deadline = deadline;

return transaction
};

Expand Down Expand Up @@ -2221,20 +2230,14 @@
}
};

const transactionParams = async ({ paymentRoute, options })=> {
const transactionParams = async ({ paymentRoute, options, deadline })=> {
if(paymentRoute.directTransfer && !paymentRoute.fee && _optionalChain$1([options, 'optionalAccess', _7 => _7.wallet, 'optionalAccess', _8 => _8.name]) !== 'World App') {
if(paymentRoute.toToken.address == Blockchains__default["default"][paymentRoute.blockchain].currency.address) {
return undefined
} else { // standard token transfer
return [paymentRoute.toAddress, paymentRoute.toAmount]
}
} else {
let deadline;
if(paymentRoute.blockchain === 'worldchain'){ // protocol V3 deadline
deadline = Math.ceil(new Date())+3600*1000; // 1 hour in ms
} else {
deadline = Math.ceil(new Date()/1000)+3600; // 1 hour in s
}
const exchangeRoute = paymentRoute.exchangeRoutes[0];
const exchangeType = getExchangeType({ exchangeRoute, blockchain: paymentRoute.blockchain });
const exchangeTransaction = !exchangeRoute ? undefined : await exchangeRoute.getTransaction({
Expand Down
2 changes: 1 addition & 1 deletion package.evm.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-payments-evm",
"moduleName": "Web3Payments",
"version": "13.12.6",
"version": "13.12.7",
"description": "JavaScript library to scan crypto wallets for liquefiable assets and perform cost-effective, auto-converted payments on-chain.",
"main": "dist/umd/index.evm.js",
"module": "dist/esm/index.evm.js",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-payments",
"moduleName": "Web3Payments",
"version": "13.12.6",
"version": "13.12.7",
"description": "JavaScript library to scan crypto wallets for liquefiable assets and perform cost-effective, auto-converted payments on-chain.",
"main": "dist/umd/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion package.solana.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-payments-solana",
"moduleName": "Web3Payments",
"version": "13.12.6",
"version": "13.12.7",
"description": "JavaScript library to scan crypto wallets for liquefiable assets and perform cost-effective, auto-converted payments on-chain.",
"main": "dist/umd/index.solana.js",
"module": "dist/esm/index.solana.js",
Expand Down
19 changes: 11 additions & 8 deletions src/platforms/evm/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,24 @@ const EXCHANGE_PROXIES = {

const getTransaction = async({ paymentRoute, options })=> {

let deadline
if(paymentRoute.blockchain === 'worldchain'){ // protocol V3 deadline
deadline = Math.ceil(new Date())+3600*1000 // 1 hour in ms
} else {
deadline = Math.ceil(new Date()/1000)+3600 // 1 hour in s
}

const transaction = {
blockchain: paymentRoute.blockchain,
to: transactionAddress({ paymentRoute, options }),
api: transactionApi({ paymentRoute, options }),
method: transactionMethod({ paymentRoute, options }),
params: await transactionParams({ paymentRoute, options }),
params: await transactionParams({ paymentRoute, options, deadline }),
value: transactionValue({ paymentRoute })
}

transaction.deadline = deadline

return transaction
}

Expand Down Expand Up @@ -183,20 +192,14 @@ const getPermit2SignatureTransferNonce = async({ address, blockchain })=>{
}
}

const transactionParams = async ({ paymentRoute, options })=> {
const transactionParams = async ({ paymentRoute, options, deadline })=> {
if(paymentRoute.directTransfer && !paymentRoute.fee && options?.wallet?.name !== 'World App') {
if(paymentRoute.toToken.address == Blockchains[paymentRoute.blockchain].currency.address) {
return undefined
} else { // standard token transfer
return [paymentRoute.toAddress, paymentRoute.toAmount]
}
} else {
let deadline
if(paymentRoute.blockchain === 'worldchain'){ // protocol V3 deadline
deadline = Math.ceil(new Date())+3600*1000 // 1 hour in ms
} else {
deadline = Math.ceil(new Date()/1000)+3600 // 1 hour in s
}
const exchangeRoute = paymentRoute.exchangeRoutes[0]
const exchangeType = getExchangeType({ exchangeRoute, blockchain: paymentRoute.blockchain })
const exchangeTransaction = !exchangeRoute ? undefined : await exchangeRoute.getTransaction({
Expand Down

0 comments on commit a6640d3

Please sign in to comment.