Skip to content

Commit

Permalink
Merge pull request #17 from PeerMeHQ/v2
Browse files Browse the repository at this point in the history
V2
  • Loading branch information
michavie authored Jul 22, 2024
2 parents 6838b40 + e0ec5c0 commit 53cf84b
Show file tree
Hide file tree
Showing 78 changed files with 1,187 additions and 630 deletions.
10 changes: 5 additions & 5 deletions dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
"dayjs": "^1.11.11",
"@headlessui/react": "^2.0.4",
"@multiversx/sdk-core": "^13.2.1",
"@multiversx/sdk-dapp": "2.33.1",
"@multiversx/sdk-dapp": "2.33.2",
"@elrondnetwork/transaction-decoder": "^1.0.0",
"@peerme/extensions": "*",
"@peerme/web-ui": "^1.17.0",
"@peerme/web-ui": "^2.0.1",
"axios": "^1.7.2",
"collect.js": "^4.36.1",
"graphql": "^16.8.1",
"next": "14.2.3",
"graphql": "^16.8.2",
"next": "14.2.4",
"react": "18.3.1",
"react-dom": "18.3.1",
"use-clipboard-copy": "^0.2.0"
Expand All @@ -32,7 +32,7 @@
"@types/react-dom": "18.3.0",
"autoprefixer": "^10.4.19",
"eslint": "9.4.0",
"eslint-config-next": "14.2.3",
"eslint-config-next": "14.2.4",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.4",
"typescript": "5.4.5"
Expand Down
16 changes: 10 additions & 6 deletions dev/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import { DevServerConfig } from './config'
import { AccountType } from '@multiversx/sdk-dapp/types'
import { ProposalAction, toActionArgsTypedValue, toActionArgsBigNumber } from '@peerme/core-ts'
import { Address, ContractFunction, Interaction, SmartContract, TokenTransfer } from '@multiversx/sdk-core'
import { ProposalAction, toActionArgsBigInt } from '@peerme/core-ts'
import { Address, Interaction, SmartContract, TokenTransfer, ContractFunction } from '@multiversx/sdk-core'

const GasLimit = 50_000_000

export const toDemoTransaction = (action: ProposalAction, account: AccountType) => {
console.log('Creating transaction for action', action, 'with account', account)

const sc = new SmartContract({ address: Address.fromBech32(action.destination) })
const typedArgs = action.arguments.map(toActionArgsTypedValue)
const typedArgs = action.arguments.map(transformActionArgToTypedValue)

console.log('Actions [serialized]', toSerializableAction(action, GasLimit))

let interaction = new Interaction(sc, new ContractFunction(action.endpoint), typedArgs)
.withChainID(DevServerConfig.ChainId)
.withSender(new Address(account.address))
.withGasLimit(50_000_000)
.withGasLimit(GasLimit)
.withNonce(account.nonce)
.withValue(action.value)

Expand All @@ -21,7 +25,7 @@ export const toDemoTransaction = (action: ProposalAction, account: AccountType)
const tokenTransfer = TokenTransfer.metaEsdtFromBigInteger(
payment.tokenId,
payment.tokenNonce,
toActionArgsBigNumber(payment.amount),
toActionArgsBigInt(payment.amount),
payment.tokenDecimals!
)
const isFungible = payment.tokenNonce === 0
Expand All @@ -31,7 +35,7 @@ export const toDemoTransaction = (action: ProposalAction, account: AccountType)
: interaction.withSingleESDTNFTTransfer(tokenTransfer)
} else if (action.payments.length > 1) {
const tokenTransfer = action.payments.map((p) =>
TokenTransfer.metaEsdtFromBigInteger(p.tokenId, p.tokenNonce, toActionArgsBigNumber(p.amount), p.tokenDecimals!)
TokenTransfer.metaEsdtFromBigInteger(p.tokenId, p.tokenNonce, toActionArgsBigInt(p.amount), p.tokenDecimals!)
)
interaction = interaction.withMultiESDTNFTTransfer(tokenTransfer)
}
Expand Down
Loading

0 comments on commit 53cf84b

Please sign in to comment.