Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to v4.4 contract #120

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion SOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ EVM:
- update createClaimXChainPayload
- update getLinkDetails
- update prepareRaffleDepositTxs
- getRaffleInfo +++++
- just CTRL+F for 'v4.2' or 'v4.3'
- change `const routerContractVersion = 'Rv4.2'`

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@squirrel-labs/peanut-sdk",
"version": "0.4.23",
"version": "0.4.24",
"description": "The Peanut Protocol SDK! Check out the documentation at https://docs.peanut.to",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/consts/eip712domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ export const GaslessReclaimTypes: any = {
GaslessReclaim: [{ name: 'depositIndex', type: 'uint256' }],
}

export const PeanutsWithEIP3009: Array<string> = ['v4.2', 'v4.3']
export const PeanutsWithGaslessRevoke: Array<string> = ['v4.2', 'v4.3']
export const PeanutsWithEIP3009: Array<string> = ['v4.2', 'v4.3', 'v4.4']
export const PeanutsWithGaslessRevoke: Array<string> = ['v4.2', 'v4.3', 'v4.4']
10 changes: 5 additions & 5 deletions src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ const TOKEN_TYPES = Object.freeze({

// CONTRACT VERSIONS
// TODO: rename CONTRACT to VAULT
const LATEST_STABLE_CONTRACT_VERSION = 'v4.3'
const LATEST_EXPERIMENTAL_CONTRACT_VERSION = 'v4.3'
const FALLBACK_CONTRACT_VERSION = 'v4.2'
const LATEST_STABLE_CONTRACT_VERSION = 'v4.4'
const LATEST_EXPERIMENTAL_CONTRACT_VERSION = 'v4.4'
const FALLBACK_CONTRACT_VERSION = 'v4.3'
const LATEST_STABLE_ROUTER_VERSION = 'Rv4'
const LATEST_EXPERIMENTAL_ROUTER_VERSION = 'Rv4'
const LATEST_STABLE_BATCHER_VERSION = 'Bv4.3'
const LATEST_EXPERIMENTAL_BATCHER_VERSION = 'Bv4.3'
const LATEST_STABLE_BATCHER_VERSION = 'Bv4.4'
const LATEST_EXPERIMENTAL_BATCHER_VERSION = 'Bv4.4'

// export all these functions (imported in index.js)
export {
Expand Down
51 changes: 38 additions & 13 deletions src/data/contracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@
"v4.2": "0x8230697B79C2F1b0b64629F67cE30B2cAa354e3d",
"Rv4.2": "0xd7a425dc8D50bF8A8c69BfE8c892D9B2CFA2Dd22",
"Bv4.3": "0x12cA3c376Cfd1BC0ac6089dc03611a148d10F9bb",
"v4.3": "0xeB429e5A3103449C5aD7a462dfe5B57f6bB516bF"
"v4.3": "0xeB429e5A3103449C5aD7a462dfe5B57f6bB516bF",
"v4.4": "0x2d26EE041fBB9CfE3dAF94B4501F4470182CE356",
"Bv4.4": "0x883788Da7b716a3D82ec53155085df02a05e7ae5"
},
"8453": {
"name": "base",
Expand All @@ -80,7 +82,9 @@
"Rv4.2": "0x67ec70F9660b0d9C1Fb0A4C6B562ebc46F0aC3E3",
"Bv4.2": "0x821D02210950193C3821e3BD3358C786483968e9",
"Bv4.3": "0xf52c585109A2CFa264433979BA3939a4087dD8E9",
"v4.3": "0xC28551dE08997e4c013F50f6E566a0F31Fc46A61"
"v4.3": "0xC28551dE08997e4c013F50f6E566a0F31Fc46A61",
"v4.4": "0x8f0c0E879B1bE72652DACfeE79dba54467B11967",
"Bv4.4": "0x0b2B87bc6F5D93BBEE6B02011d4174bEa1F1eB89"
},
"10": {
"name": "optimism-mainnet",
Expand All @@ -93,7 +97,9 @@
"v4.2": "0xD9E3b11e700680C1b8b69B1fa990a2765EdBb3f7",
"Bv4.2": "0x60CA4C66744479cCFCDB416c52Cbc04f6f1E8e0B",
"Bv4.3": "0x47FaA93dC12Aa8970da56Cb49e69283CE511a42A",
"v4.3": "0xb75B6e4007795e84a0f9Db97EB19C6Fc13c84A5E"
"v4.3": "0xb75B6e4007795e84a0f9Db97EB19C6Fc13c84A5E",
"v4.4": "0x1ACF2C8B4Dc01a9617592b88BCFc4Fad751360bE",
"Bv4.4": "0x2414CCC6fc5B9369bB84e8Ff0C846A4cBf17e39d"
},
"42161": {
"name": "arbitrum-mainnet",
Expand All @@ -107,7 +113,8 @@
"Bv4.2": "0x7560Ab3ffAD59D09aEA7b7Fc53E52664d5E71c74",
"Bv4.3": "0xF681c5B378882a3D8Df5170B579e1503EB97C275",
"v4.3": "0x43B90099a203957F1adf35Dde15ac88b3e323e75",
"v4.4": "0x7f573556E25Fc952838bE811612136DE1522992B"
"v4.4": "0xe8A4c1DC1E30E01b7D9471FE0422A60beE3fa36c",
"Bv4.4": "0xB41656294EE211E8B89c83AB16AB5Cef5770D3ee"
},
"100": {
"name": "xdai-mainnet",
Expand All @@ -119,7 +126,9 @@
"Rv4.2": "0x789430A2776b135b2eA363096eCD78F16118EFFC",
"v4.2": "0xdB60C736A30C41D9df0081057Eae73C3eb119895",
"Bv4.3": "0x79F7965434a01949331D5457253A05226aDdCAC4",
"v4.3": "0xa77fDfE0f0Ad47356cF50cE31E4dA538552690A1"
"v4.3": "0xa77fDfE0f0Ad47356cF50cE31E4dA538552690A1",
"Bv4.4": "0x68b450EC5E922143Fe6b223D8AD63dB24d6fC669",
"v4.4": "0x108476aCb5E7Fad5CD71CC77EbD617e1b9006a76"
},
"2001": {
"name": "milkomeda-c1",
Expand Down Expand Up @@ -149,7 +158,9 @@
"Rv4.2": "0xF5D83DF662f58255D9E9d5fe9a59ac7Cd1eF85BC",
"v4.2": "0xf2032be6A227055192c03Ad91EDFFCEec9Ed5b4F",
"v4.3": "0x2e0092beE1fF5902278D64d4E760920C6Fd10974",
"Bv4.3": "0xCf6d9e5eFFde4A418d22C13021720847Ffb68Eb7"
"Bv4.3": "0xCf6d9e5eFFde4A418d22C13021720847Ffb68Eb7",
"v4.4": "0xd092f910be70328426530bCa92C746De1e0989eC",
"Bv4.4": "0xE9963b5f864099c3A4454c395C8Cf1bBd97eCA91"
},
"59144": {
"name": "linea",
Expand All @@ -159,19 +170,25 @@
"Rv4.2": "0x4ab4EED6455DdE117180108ea606c25ed2e95150",
"v4.2": "0xa4Ce60d7dd66207b11fd16feb346Bf7927DDC359",
"Bv4.3": "0x67978Db395C2877b84Fb97cEEA1B0C0974f443E9",
"v4.3": "0x90b665736796A6ABe4dC9D33Fd125F35F6655514"
"v4.3": "0x90b665736796A6ABe4dC9D33Fd125F35F6655514",
"v4.4": "0x108476aCb5E7Fad5CD71CC77EbD617e1b9006a76",
"Bv4.4": "0xD1B4957649a41C61477373636966C83Bf14Ee096"
},
"324": {
"name": "zksync-era-mainnet",
"mainnet": "true",
"v4": "0x0f8d307723107d3A466223E09113A1EE6f8411DF",
"v4.2": "0xF6F3927552bE1137A823417A0a6eBdB883B72e17"
"v4.2": "0xF6F3927552bE1137A823417A0a6eBdB883B72e17",
"v4.4": "0xFC66df3A544e558c1546bBdb9A2a735ee5516351",
"Bv4.4": "0x3A1ce6fdc14953B8889A0070BF1Ae4D1C0F3Bb97"
},
"300": {
"name": "zksync-era-sepolia",
"mainnet": "false",
"v4": "0xC39dC50b46BE62B8f209853E2D36E1Fcab349404",
"v4.2": "0x392bF7Ea002F3630EC3cF559557dA8526cF63aCc"
"v4.2": "0x392bF7Ea002F3630EC3cF559557dA8526cF63aCc",
"v4.4": "0x96e70DdA776B3B8bEb195b92E116ABA1DBe1100B",
"Bv4.4": "0x1469E2AE9C0F80Da48a9FBe3070C85A5d892e1D3"
},
"534352": {
"name": "scroll",
Expand All @@ -181,7 +198,9 @@
"v4.3": "0xdea734a6fe724d43d39e88a8794e1f573f81bf49",
"Rv4.2": "0xB0CE4b507D424d9E019EfE7F4d00FF78501E69A4",
"Bv4.2": "0xe8EEAa2EAf9571F587da13d262b35fd3e18D0801",
"Bv4.3": "0x1b8a0f4e60c7566cb092c1d39eb06c0401f8977a"
"Bv4.3": "0x1b8a0f4e60c7566cb092c1d39eb06c0401f8977a",
"v4.4": "0xa4307769B01fd62211BE087f87FAa8C9b610DfE6",
"Bv4.4": "0x4F64E39F8aFDd329e6c1F2dDbcc1566d11ee07da"
},
"5000": {
"name": "mantle",
Expand All @@ -190,7 +209,9 @@
"Bv4.2": "0x7B36e10AA3ff44576efF4b1AfB80587B9b3BA3a5",
"Rv4.2": "0x897F8EDdB345F0d16081615823F76055Ad60A00c",
"v4.3": "0xB0CE4b507D424d9E019EfE7F4d00FF78501E69A4",
"Bv4.3": "0x9C396f63E3BD0Bd529c28344154A73767eB63E2d"
"Bv4.3": "0x9C396f63E3BD0Bd529c28344154A73767eB63E2d",
"v4.4": "0xF70326d622aD4A890e51d447f48945f51db82151",
"Bv4.4": "0x5aC58e7dD5e3FCe5909dE8F9ed3454D3304552e5"
},
"5001": {
"name": "mantle-testnet",
Expand Down Expand Up @@ -218,12 +239,16 @@
"name": "celo-alfajores",
"mainnet": "false",
"v4.3": "0x5c1b67ED2809e371aabbc58D934282E8Aa7E3fd4",
"Rv4.2": "0xa1F413760E942dbbBDD36589526A11f4C013085b"
"Rv4.2": "0xa1F413760E942dbbBDD36589526A11f4C013085b",
"v4.4": "0x69Ec2ed8ee656f249FE87a24195E9139b2aacbc1",
"Bv4.4": "0xc74D497f5c00e77F80b528154f7458b2C4370bF3"
},
"42220": {
"name": "celo",
"mainnet": "true",
"Rv4.2": "0x8d1a17A3A4504aEB17515645BA8098f1D75237f7",
"v4.3": "0x7B36e10AA3ff44576efF4b1AfB80587B9b3BA3a5"
"v4.3": "0x7B36e10AA3ff44576efF4b1AfB80587B9b3BA3a5",
"v4.4": "0x91Eb3443fc348e2C35941419Ab9ee9D26eC3270B",
"Bv4.4": "0x0D3492437E86dabb67F2bCfAE5c597D2edA67D65"
}
}
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,7 @@ async function createClaimXChainPayload({
const contractVersion = linkParams.contractVersion
const password = linkParams.password

if (contractVersion !== 'v4.2' && contractVersion !== 'v4.3') {
if (!['v4.2', 'v4.3', 'v4.4'].includes(contractVersion)) {
throw new interfaces.SDKStatus(
interfaces.EXChainStatusCodes.ERROR_UNSUPPORTED_CONTRACT_VERSION,
`Unsupported contract version ${contractVersion}`
Expand Down Expand Up @@ -1749,7 +1749,7 @@ async function getLinkDetails({ link, provider }: interfaces.IGetLinkDetailsPara
}

let depositDate: Date | null = null
if (['v4', 'v4.2', 'v4.3'].includes(contractVersion)) {
if (['v4', 'v4.2', 'v4.3', 'v4.4'].includes(contractVersion)) {
if (deposit.timestamp) {
depositDate = new Date(deposit.timestamp * 1000)
if (deposit.timestamp == 0) {
Expand Down Expand Up @@ -2309,7 +2309,7 @@ async function getAllUnclaimedDepositsWithIdxForAddress({
provider = await getDefaultProvider(chainId)
}

if (!['v4', 'v4.2', 'v4.3'].includes(peanutContractVersion)) {
if (!['v4', 'v4.2', 'v4.3', 'v4.4'].includes(peanutContractVersion)) {
console.error('ERROR: can only return unclaimed deposits for v4+ contracts')
return
}
Expand Down
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export function getDepositIdx(txReceipt: any, chainId: string, contractVersion:
//@HUGO: I've removed the parseInt here since it's already a bigInt
depositIdx = BigInt(depositIdxHex)
}
} else if (['v4', 'V4.2', 'v4.3'].includes(contractVersion)) {
} else if (['v4', 'V4.2', 'v4.3', 'v4.4'].includes(contractVersion)) {
// In v4+, the index is now an indexed topic rather than part of the log data
try {
// Based on the etherscan example, the index is now the 1st topic.
Expand Down
4 changes: 2 additions & 2 deletions test/basic/getLatestContractVersion.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import peanut from '../../src/index' // import directly from source code
describe('getLatestContractVersion', () => {
const expectedVersionNormal = 'v4.3'
const expectedVersionBatch = 'Bv4.3'
const expectedVersionNormal = 'v4.4'
const expectedVersionBatch = 'Bv4.4'
const types = ['normal', 'batch']

const chainIds = ['5', '137', '5000', '5001']
Expand Down
12 changes: 6 additions & 6 deletions test/live/raffle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('raffle', () => {
config.verbose && console.log('Using wallet:', wallet.address)

const password = await getRandomString()
const numberOfLinks = 2
const numberOfLinks = 10
const withMFA = true
const linkDetails: interfaces.IPeanutLinkDetails = {
chainId,
Expand All @@ -97,7 +97,7 @@ describe('raffle', () => {
const { unsignedTxs } = await prepareRaffleDepositTxs({
linkDetails,
numberOfLinks,
tokenIds: [BigNumber.from(6), BigNumber.from(7)],
tokenIds: Array.from(Array(numberOfLinks).keys()).map((value) => BigNumber.from(value)),
password,
userAddress: wallet.address,
withMFA,
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('raffle', () => {
withMFA,
withCaptcha: false,
APIKey,
baseUrl: 'http://localhost:8000/submit-raffle-link',
// baseUrl: 'http://localhost:8000/submit-raffle-link',
withENS: false,
withSignedMessage: false,
withWeb3Email: false,
Expand Down Expand Up @@ -154,14 +154,14 @@ describe('raffle', () => {
APIKey,
recipientAddress,
recipientName: 'amobest',
baseUrlAuth: 'http://localhost:8000/get-authorisation',
baseUrlClaim: 'http://localhost:8000/claim-v2',
// baseUrlAuth: 'http://localhost:8000/get-authorisation',
// baseUrlClaim: 'http://localhost:8000/claim-v2',
})
console.log('Claimed a raffle slot!!', claimInfo)
const leaderboard = await getRaffleLeaderboard({
link,
APIKey,
baseUrl: 'http://localhost:8000/get-raffle-leaderboard'
// baseUrl: 'http://localhost:8000/get-raffle-leaderboard'
})
console.log('Hooouray, leaderboard!', { leaderboard })
}, 120000)
Expand Down
Loading