-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement 'Batch' builder for EVM Parachains (#371)
* update mrl example * implement Batch contract builder for sending assets and xcm message with remote execution * fix code * update lock file * fix lint problem * fix linter issues from sovereign account balance checking implementations * fix sovereign account balance checking implementation
- Loading branch information
Showing
22 changed files
with
1,097 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { type AnyParachain, EvmParachain } from '@moonbeam-network/xcm-types'; | ||
import { u8aToHex } from '@polkadot/util'; | ||
import { decodeAddress } from '@polkadot/util-crypto'; | ||
import type { Address } from 'viem'; | ||
|
||
export function getPrecompileDestinationInterior( | ||
destination: AnyParachain, | ||
address?: string, | ||
): [Address, Address] | [Address] { | ||
if (!address) { | ||
return [`0x0000000${destination.parachainId.toString(16)}`]; | ||
} | ||
|
||
/* | ||
01: AccountId32 | ||
03: AccountKey20 | ||
https://docs.moonbeam.network/builders/interoperability/xcm/xc20/xtokens/#building-the-precompile-multilocation | ||
*/ | ||
const accountType = EvmParachain.is(destination) ? '03' : '01'; | ||
const acc = `0x${accountType}${u8aToHex( | ||
decodeAddress(address), | ||
-1, | ||
false, | ||
)}00` as Address; | ||
|
||
return destination.parachainId | ||
? [`0x0000000${destination.parachainId.toString(16)}`, acc] | ||
: [acc]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.