-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fix crossChainTransfer for the changes in adapter. fix #137 #138
Conversation
|
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a few suggestions.
}; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default xtokens; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are multiple exports, we can use export {abi, address}
. That’s why eslint recommends import/no-default-export
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
const moonbeam = { xtokens }; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default moonbeam; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export { moonbeam }
; since we will add more chains to this object later, such as {acala, moonbeam, astar}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
const contracts = { astar, moonbeam }; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default contracts; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try the below lines,
import * from `./astar`;
import * from `./moonbeam`;
export {astar, moonbeam};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
packages/adapter/src/utils.ts
Outdated
/** | ||
* Determine the account type based on the address. | ||
* Because 1 byte takes 2 characters in hex string, we can use the length of the address to determine the address type. | ||
* AccountKey20: 42 characters with prefix 0x. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s add the 0x check to this function.
const length = _.startWith(address, "0x")? 42: 40;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
packages/adapter/src/utils.ts
Outdated
* Determine the account type based on the address. | ||
* Because 1 byte takes 2 characters in hex string, we can use the length of the address to determine the address type. | ||
* AccountKey20: 42 characters with prefix 0x. | ||
* AccountId32: 66 characters with prefix 0x. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No substrate wallet address contains "0x", so AccountId32 length check should be 64. This function needs to throw an error on all wrong cases instead of using AccountType.AccountId32 as the fall-back.
For example,
if starts with 0x
if length is 42
AccountType.AccountKey20
else
if length is 40
AccountType.AccountKey20
if length is 64
AccountType.AccountId32
throw new Error(`Unrecognized address format`);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, the changes look good 👌
* Determine the account type based on the address. * Cross-chain transfer with eth signer * Convert location to precompile multi-location * Add docs references for convertLocationToPrecompileMultiLocation function * Add astar crossChainTransferWithEthSigner function * Set the correct unlimitedWeight when calling astar contract call * Move contract utils to contract-utils.ts * Fix the error in finding the selector * Modify the export method of contracts * Fix the conversion from bytes to bits * An example explaining how to calculate the accountId32 from a Substrate address
* Determine the account type based on the address. * Cross-chain transfer with eth signer * Convert location to precompile multi-location * Add docs references for convertLocationToPrecompileMultiLocation function * Add astar crossChainTransferWithEthSigner function * Set the correct unlimitedWeight when calling astar contract call * Move contract utils to contract-utils.ts * Fix the error in finding the selector * Modify the export method of contracts * Fix the conversion from bytes to bits * An example explaining how to calculate the accountId32 from a Substrate address
crossChainTransferWithEthSigner
function. It is implemented by calling thextokens
contract on Moonriver.crossChainTransferWithEthSigner
function. It is implemented by calling thexcm
contract on Shiden.