Skip to content

Commit

Permalink
chore: optimize alephium params
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteZhang1024 committed Aug 13, 2024
1 parent ce7ebf9 commit 6e21921
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
21 changes: 18 additions & 3 deletions packages/example/components/chains/alephium/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,21 @@ export function Example() {
wallet?.account?.address ?? '',
)}
onExecute={async (request: string) => {
return wallet.signer.signAndSubmitTransferTx(JSON.parse(request));
const params = JSON.parse(request);
return wallet.signer.signAndSubmitTransferTx({
...params,
destinations: params.destinations.map((destination: any) => ({
address: destination?.address,
attoAlphAmount: destination?.amount?.toString(),
tokens: destination?.tokens?.map((token: any) => ({
id: token?.id,
amount: token?.amount?.toString(),
})),
lockTime: destination?.lockTime,
message: destination?.message,
})),
signerAddress: params.signerAddress,
});
}}
/>
<ApiPayload
Expand Down Expand Up @@ -71,7 +85,8 @@ export function Example() {
onExecute={async (request: string) => {
return wallet.signer.signUnsignedTx(JSON.parse(request));
}}
/><ApiPayload
/>
<ApiPayload
title="signMessage"
description=""
allowCallWithoutProvider={!!wallet}
Expand All @@ -89,7 +104,7 @@ export function Example() {

export default function App() {
return (
<AlephiumWalletProvider network="mainnet" theme="retro">
<AlephiumWalletProvider network="testnet" theme="retro">
<Example />
</AlephiumWalletProvider>
);
Expand Down
20 changes: 10 additions & 10 deletions packages/example/components/chains/alephium/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ export default {
destinations: [
{
address: to,
amount: '20000000',
amount: ONE_ALPH.toString(),
},
],
}),
},
{
id: 'signAndSubmitTransferTx-token',
id: 'signAndSubmitTransferTx-token-638b022292ea665dc9c946eec02ef9602926dc0e6db17143baebce898e34a302',
name: 'Token',
value: JSON.stringify({
signerAddress: from,
destinations: [
{
address: to,
amount: DUST_AMOUNT,
tokens: [{ id: 'tokenId', amount: 10 }],
amount: DUST_AMOUNT.toString(),
tokens: [{ id: '638b022292ea665dc9c946eec02ef9602926dc0e6db17143baebce898e34a302', amount: 10n }],
},
],
}),
Expand All @@ -33,23 +33,23 @@ export default {
signAndSubmitDeployContractTx: (from: string) => {
return [
{
id: 'signAndSubmitDeployContractTx-native',
name: 'Native with body',
id: 'signAndSubmitDeployContractTx-test',
name: 'Deploy test contract',
value: JSON.stringify({
signerAddress: from,
bytecode: '010203',
bytecode: '000117010100000004d362d46012b413c40de0b6b3a7640000a90000',
}),
},
];
},
signAndSubmitExecuteScriptTx: (from: string) => {
return [
{
id: 'signAndSubmitExecuteScriptTx-native',
name: 'Native with body',
id: 'signAndSubmitExecuteScriptTx-call-test-contract',
name: 'call test contract',
value: JSON.stringify({
signerAddress: from,
bytecode: '010203',
bytecode: '01010300000007b413c40de0b6b3a7640000a20c0c1440206c3b1f6262ffad9a4cb1e78f03f17f3593837505a69edbc18a59cf23c1f1c4020100',
}),
},
];
Expand Down

0 comments on commit 6e21921

Please sign in to comment.