@heliofi/evm-adapter
Advanced tools
Comparing version 1.1.1-beta1 to 2.0.0
@@ -11,40 +11,3 @@ "use strict"; | ||
{ | ||
indexed: true, | ||
internalType: 'address', | ||
name: 'sender', | ||
type: 'address', | ||
}, | ||
{ | ||
indexed: true, | ||
internalType: 'address', | ||
name: 'recipient', | ||
type: 'address', | ||
}, | ||
{ | ||
indexed: false, | ||
internalType: 'uint256', | ||
name: 'transferAmount', | ||
type: 'uint256', | ||
}, | ||
{ | ||
indexed: false, | ||
internalType: 'uint256', | ||
name: 'feeAmount', | ||
type: 'uint256', | ||
}, | ||
{ | ||
indexed: false, | ||
internalType: 'string', | ||
name: 'transactionDbId', | ||
type: 'string', | ||
}, | ||
], | ||
name: 'EthPayment', | ||
type: 'event', | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ | ||
indexed: false, | ||
internalType: 'uint8', | ||
@@ -70,8 +33,2 @@ name: 'version', | ||
internalType: 'address', | ||
name: 'recipient', | ||
type: 'address', | ||
}, | ||
{ | ||
indexed: true, | ||
internalType: 'address', | ||
name: 'tokenAddress', | ||
@@ -87,45 +44,2 @@ type: 'address', | ||
{ | ||
indexed: false, | ||
internalType: 'uint256', | ||
name: 'feeAmount', | ||
type: 'uint256', | ||
}, | ||
{ | ||
indexed: false, | ||
internalType: 'string', | ||
name: 'transactionDbId', | ||
type: 'string', | ||
}, | ||
], | ||
name: 'Payment', | ||
type: 'event', | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ | ||
indexed: true, | ||
internalType: 'address', | ||
name: 'sender', | ||
type: 'address', | ||
}, | ||
{ | ||
indexed: true, | ||
internalType: 'address', | ||
name: 'recipient', | ||
type: 'address', | ||
}, | ||
{ | ||
indexed: false, | ||
internalType: 'uint256', | ||
name: 'transferAmount', | ||
type: 'uint256', | ||
}, | ||
{ | ||
indexed: false, | ||
internalType: 'uint256', | ||
name: 'feeAmount', | ||
type: 'uint256', | ||
}, | ||
{ | ||
components: [ | ||
@@ -155,112 +69,6 @@ { | ||
], | ||
name: 'SplitEthPayment', | ||
name: 'Payment2', | ||
type: 'event', | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ | ||
indexed: true, | ||
internalType: 'address', | ||
name: 'sender', | ||
type: 'address', | ||
}, | ||
{ | ||
indexed: true, | ||
internalType: 'address', | ||
name: 'recipient', | ||
type: 'address', | ||
}, | ||
{ | ||
indexed: true, | ||
internalType: 'address', | ||
name: 'tokenAddress', | ||
type: 'address', | ||
}, | ||
{ | ||
indexed: false, | ||
internalType: 'uint256', | ||
name: 'transferAmount', | ||
type: 'uint256', | ||
}, | ||
{ | ||
indexed: false, | ||
internalType: 'uint256', | ||
name: 'feeAmount', | ||
type: 'uint256', | ||
}, | ||
{ | ||
components: [ | ||
{ | ||
internalType: 'address', | ||
name: 'recipient', | ||
type: 'address', | ||
}, | ||
{ | ||
internalType: 'uint256', | ||
name: 'amount', | ||
type: 'uint256', | ||
}, | ||
], | ||
indexed: false, | ||
internalType: 'struct IHelio.RecipientAndAmount[]', | ||
name: 'splitData', | ||
type: 'tuple[]', | ||
}, | ||
{ | ||
indexed: false, | ||
internalType: 'string', | ||
name: 'transactionDbId', | ||
type: 'string', | ||
}, | ||
], | ||
name: 'SplitPayment', | ||
type: 'event', | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: 'address', | ||
name: 'recipient', | ||
type: 'address', | ||
}, | ||
{ | ||
internalType: 'uint256', | ||
name: 'amount', | ||
type: 'uint256', | ||
}, | ||
{ | ||
internalType: 'uint16', | ||
name: 'feeBps', | ||
type: 'uint16', | ||
}, | ||
{ | ||
internalType: 'string', | ||
name: 'transactionDbId', | ||
type: 'string', | ||
}, | ||
{ | ||
components: [ | ||
{ | ||
internalType: 'address', | ||
name: 'recipient', | ||
type: 'address', | ||
}, | ||
{ | ||
internalType: 'uint16', | ||
name: 'feeBps', | ||
type: 'uint16', | ||
}, | ||
], | ||
internalType: 'struct IHelio.FeeAndAddress[]', | ||
name: 'splitFeeData', | ||
type: 'tuple[]', | ||
}, | ||
], | ||
name: 'ethPayment', | ||
outputs: [], | ||
stateMutability: 'payable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [], | ||
@@ -276,7 +84,2 @@ name: 'initialize', | ||
internalType: 'address', | ||
name: 'recipient', | ||
type: 'address', | ||
}, | ||
{ | ||
internalType: 'address', | ||
name: 'tokenAddress', | ||
@@ -286,17 +89,2 @@ type: 'address', | ||
{ | ||
internalType: 'uint256', | ||
name: 'amount', | ||
type: 'uint256', | ||
}, | ||
{ | ||
internalType: 'uint16', | ||
name: 'feeBps', | ||
type: 'uint16', | ||
}, | ||
{ | ||
internalType: 'string', | ||
name: 'transactionDbId', | ||
type: 'string', | ||
}, | ||
{ | ||
components: [ | ||
@@ -309,42 +97,2 @@ { | ||
{ | ||
internalType: 'uint16', | ||
name: 'feeBps', | ||
type: 'uint16', | ||
}, | ||
], | ||
internalType: 'struct IHelio.FeeAndAddress[]', | ||
name: 'splitFeeData', | ||
type: 'tuple[]', | ||
}, | ||
], | ||
name: 'payment', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: 'address', | ||
name: 'recipient', | ||
type: 'address', | ||
}, | ||
{ | ||
internalType: 'uint256', | ||
name: 'amount', | ||
type: 'uint256', | ||
}, | ||
{ | ||
internalType: 'uint16', | ||
name: 'feeBps', | ||
type: 'uint16', | ||
}, | ||
{ | ||
components: [ | ||
{ | ||
internalType: 'address', | ||
name: 'recipient', | ||
type: 'address', | ||
}, | ||
{ | ||
internalType: 'uint256', | ||
@@ -364,21 +112,4 @@ name: 'amount', | ||
}, | ||
{ | ||
components: [ | ||
{ | ||
internalType: 'address', | ||
name: 'recipient', | ||
type: 'address', | ||
}, | ||
{ | ||
internalType: 'uint16', | ||
name: 'feeBps', | ||
type: 'uint16', | ||
}, | ||
], | ||
internalType: 'struct IHelio.FeeAndAddress[]', | ||
name: 'splitFeeData', | ||
type: 'tuple[]', | ||
}, | ||
], | ||
name: 'splitEthPayment', | ||
name: 'payment', | ||
outputs: [], | ||
@@ -388,71 +119,4 @@ stateMutability: 'payable', | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: 'address', | ||
name: 'recipient', | ||
type: 'address', | ||
}, | ||
{ | ||
internalType: 'address', | ||
name: 'tokenAddress', | ||
type: 'address', | ||
}, | ||
{ | ||
internalType: 'uint256', | ||
name: 'amount', | ||
type: 'uint256', | ||
}, | ||
{ | ||
internalType: 'uint16', | ||
name: 'feeBps', | ||
type: 'uint16', | ||
}, | ||
{ | ||
components: [ | ||
{ | ||
internalType: 'address', | ||
name: 'recipient', | ||
type: 'address', | ||
}, | ||
{ | ||
internalType: 'uint256', | ||
name: 'amount', | ||
type: 'uint256', | ||
}, | ||
], | ||
internalType: 'struct IHelio.RecipientAndAmount[]', | ||
name: 'splitData', | ||
type: 'tuple[]', | ||
}, | ||
{ | ||
internalType: 'string', | ||
name: 'transactionDbId', | ||
type: 'string', | ||
}, | ||
{ | ||
components: [ | ||
{ | ||
internalType: 'address', | ||
name: 'recipient', | ||
type: 'address', | ||
}, | ||
{ | ||
internalType: 'uint16', | ||
name: 'feeBps', | ||
type: 'uint16', | ||
}, | ||
], | ||
internalType: 'struct IHelio.FeeAndAddress[]', | ||
name: 'splitFeeData', | ||
type: 'tuple[]', | ||
}, | ||
], | ||
name: 'splitPayment', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
], | ||
}; | ||
//# sourceMappingURL=helio.js.map |
export * from './helio'; | ||
export * from './helioEth'; | ||
export * from './erc20'; | ||
export * from './erc721'; | ||
export * from './erc1155'; |
@@ -18,3 +18,2 @@ "use strict"; | ||
__exportStar(require("./helio"), exports); | ||
__exportStar(require("./helioEth"), exports); | ||
__exportStar(require("./erc20"), exports); | ||
@@ -21,0 +20,0 @@ __exportStar(require("./erc721"), exports); |
@@ -1,2 +0,1 @@ | ||
import { BigNumber } from 'ethers'; | ||
export declare enum ChainId { | ||
@@ -16,2 +15,1 @@ ETHEREUM_MAINNET = 1, | ||
} | ||
export declare const gasLimit: BigNumber; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.gasLimit = exports.ContractAddress = exports.ChainId = void 0; | ||
const ethers_1 = require("ethers"); | ||
exports.ContractAddress = exports.ChainId = void 0; | ||
var ChainId; | ||
@@ -21,3 +20,2 @@ (function (ChainId) { | ||
})(ContractAddress = exports.ContractAddress || (exports.ContractAddress = {})); | ||
exports.gasLimit = ethers_1.BigNumber.from(ethers_1.utils.hexlify('0x060000')); | ||
//# sourceMappingURL=constants.js.map |
@@ -20,4 +20,12 @@ import { RecipientAndAmount } from './types'; | ||
}; | ||
export type Payment2Event = { | ||
sender: string; | ||
tokenAddress: string; | ||
transferAmount: bigint; | ||
splitData: RecipientAndAmount[]; | ||
transactionDbId: string; | ||
}; | ||
export declare enum EventName { | ||
PAYMENT = "Payment", | ||
PAYMENT2 = "Payment2", | ||
ETH_PAYMENT = "EthPayment", | ||
@@ -24,0 +32,0 @@ SPLIT_PAYMENT = "SplitPayment", |
@@ -7,2 +7,3 @@ "use strict"; | ||
EventName["PAYMENT"] = "Payment"; | ||
EventName["PAYMENT2"] = "Payment2"; | ||
EventName["ETH_PAYMENT"] = "EthPayment"; | ||
@@ -9,0 +10,0 @@ EventName["SPLIT_PAYMENT"] = "SplitPayment"; |
import { BaseProvider } from '@ethersproject/providers'; | ||
import { PaymentRequest } from './types'; | ||
export declare const getPaymentTx: (provider: BaseProvider, req: PaymentRequest) => Promise<import("ethers").PopulatedTransaction>; | ||
import { PaymentRequest, RecipientAndAmount } from './types'; | ||
export declare const getPaymentTx: (provider: BaseProvider, req: PaymentRequest, recipientsAndAmounts: RecipientAndAmount[]) => Promise<import("ethers").PopulatedTransaction>; |
@@ -5,5 +5,5 @@ "use strict"; | ||
const ethers_1 = require("ethers"); | ||
const constants_1 = require("./constants"); | ||
const abi_1 = require("./abi"); | ||
const utils_1 = require("./utils"); | ||
const getPaymentTx = async (provider, req) => { | ||
const getPaymentTx = async (provider, req, recipientsAndAmounts) => { | ||
const { chainId } = await provider.getNetwork(); | ||
@@ -14,19 +14,13 @@ const contractAddress = (0, utils_1.getContractAddress)(chainId); | ||
} | ||
const contract = new ethers_1.Contract(contractAddress, (0, utils_1.getAbi)(chainId), provider); | ||
const amount = ethers_1.BigNumber.from(req.amount); | ||
const feesAndAddresses = (0, utils_1.getFeesAndAddresses)(req); | ||
const params = [ | ||
req.recipientAddress, | ||
req.tokenAddres, | ||
amount, | ||
ethers_1.BigNumber.from(req.fee), | ||
req.transactonDbId, | ||
]; | ||
if ((0, utils_1.isPolygon)(chainId)) { | ||
params.push(feesAndAddresses); | ||
} | ||
const unsignedTx = await contract.populateTransaction.payment(...params, { | ||
gasLimit: constants_1.gasLimit, | ||
gasPrice: await provider.getGasPrice(), | ||
}); | ||
const contract = new ethers_1.Contract(contractAddress, abi_1.helio.abi, provider); | ||
const BNRecipientsAndAmounts = recipientsAndAmounts.map((r) => ({ | ||
recipient: r.recipient, | ||
amount: ethers_1.BigNumber.from(r.amount), | ||
})); | ||
const valueOverride = Number(req.tokenAddres) === 0 | ||
? { | ||
value: recipientsAndAmounts.reduce((acc, r) => acc + r.amount, 0n), | ||
} | ||
: undefined; | ||
const unsignedTx = await contract.populateTransaction.payment(req.tokenAddres, BNRecipientsAndAmounts, req.transactonDbId, valueOverride); | ||
unsignedTx.chainId = chainId; | ||
@@ -33,0 +27,0 @@ return unsignedTx; |
@@ -5,2 +5,3 @@ "use strict"; | ||
const ethers_1 = require("ethers"); | ||
const abi_1 = require("./abi"); | ||
const constants_1 = require("./constants"); | ||
@@ -14,3 +15,3 @@ const utils_1 = require("./utils"); | ||
} | ||
const contract = new ethers_1.Contract(contractAddress, (0, utils_1.getAbi)(chainId), provider); | ||
const contract = new ethers_1.Contract(contractAddress, abi_1.helio.abi, provider); | ||
const BNRecipientsAndAmounts = recipientsAndAmounts.map((r) => ({ | ||
@@ -20,15 +21,3 @@ recipient: r.recipient, | ||
})); | ||
const feesAndAddresses = (0, utils_1.getFeesAndAddresses)(req); | ||
const params = [ | ||
req.recipientAddress, | ||
req.tokenAddres, | ||
ethers_1.BigNumber.from(req.amount), | ||
ethers_1.BigNumber.from(req.fee), | ||
BNRecipientsAndAmounts, | ||
req.transactonDbId, | ||
]; | ||
if ((0, utils_1.isPolygon)(chainId)) { | ||
params.push(feesAndAddresses); | ||
} | ||
const unsignedTx = await contract.populateTransaction.splitPayment(...params, { | ||
const unsignedTx = await contract.populateTransaction.splitPayment(req.recipientAddress, req.tokenAddres, ethers_1.BigNumber.from(req.amount), ethers_1.BigNumber.from(req.fee), BNRecipientsAndAmounts, req.transactonDbId, { | ||
gasLimit: constants_1.gasLimit, | ||
@@ -35,0 +24,0 @@ gasPrice: await provider.getGasPrice(), |
export * from './getPaymentTx'; | ||
export * from './getSplitPaymentTx'; | ||
export * from './getEthPaymentTx'; | ||
export * from './getSplitEthPaymentTx'; | ||
export * from './requestTokenAmountApproval'; | ||
@@ -6,0 +3,0 @@ export * from './types'; |
@@ -18,5 +18,2 @@ "use strict"; | ||
__exportStar(require("./getPaymentTx"), exports); | ||
__exportStar(require("./getSplitPaymentTx"), exports); | ||
__exportStar(require("./getEthPaymentTx"), exports); | ||
__exportStar(require("./getSplitEthPaymentTx"), exports); | ||
__exportStar(require("./requestTokenAmountApproval"), exports); | ||
@@ -23,0 +20,0 @@ __exportStar(require("./types"), exports); |
@@ -5,14 +5,5 @@ export type RecipientAndAmount = { | ||
}; | ||
export type FeeAndAddress = { | ||
recipient: string; | ||
feeBps: number; | ||
}; | ||
export type PaymentRequest = { | ||
walletAddress: string; | ||
recipientAddress: string; | ||
amount: bigint; | ||
fee: number; | ||
transactonDbId: string; | ||
tokenAddres?: string; | ||
feesAndAddresses?: FeeAndAddress[]; | ||
tokenAddres: string; | ||
}; |
@@ -1,9 +0,1 @@ | ||
import { BigNumber, ContractInterface } from 'ethers'; | ||
import { PaymentRequest } from './types'; | ||
export declare const getContractAddress: (chainIdNr: number) => string | undefined; | ||
export declare const getFeesAndAddresses: (req: PaymentRequest) => { | ||
recipient: string; | ||
feeBps: BigNumber; | ||
}[]; | ||
export declare const isPolygon: (chainId: number) => boolean; | ||
export declare const getAbi: (chainIdNr: number) => ContractInterface; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getAbi = exports.isPolygon = exports.getFeesAndAddresses = exports.getContractAddress = void 0; | ||
const ethers_1 = require("ethers"); | ||
const abi_1 = require("./abi"); | ||
exports.getContractAddress = void 0; | ||
const constants_1 = require("./constants"); | ||
const getContractAddress = (chainIdNr) => chainIdNr in constants_1.ChainId ? constants_1.ContractAddress[constants_1.ChainId[chainIdNr]] : undefined; | ||
exports.getContractAddress = getContractAddress; | ||
const getFeesAndAddresses = (req) => { | ||
const feesAndAddresses = req.feesAndAddresses || []; | ||
return feesAndAddresses.map((feeAndAddress) => ({ | ||
recipient: feeAndAddress.recipient, | ||
feeBps: ethers_1.BigNumber.from(feeAndAddress.feeBps), | ||
})); | ||
}; | ||
exports.getFeesAndAddresses = getFeesAndAddresses; | ||
const isPolygon = (chainId) => chainId === constants_1.ChainId.POLYGON_MUMBAI || chainId === constants_1.ChainId.POLYGON_MAINNET; | ||
exports.isPolygon = isPolygon; | ||
const getAbi = (chainIdNr) => (0, exports.isPolygon)(chainIdNr) ? abi_1.helio.abi : abi_1.helioEth.abi; | ||
exports.getAbi = getAbi; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "@heliofi/evm-adapter", | ||
"version": "1.1.1-beta1", | ||
"version": "2.0.0", | ||
"description": "API to interact with Helio Finances program on EVM chains.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
91615
1906