-
Notifications
You must be signed in to change notification settings - Fork 49
refactor: retrieve contract address from Instantiated event #589
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d5347fc
fix: getContractInfo for latest pallet revive changes
AlexD10S 19f660c
chore: update tests for v6.0.0-alpha.3
AlexD10S 2baf84b
refactor: get smart contract address from event
AlexD10S b377803
refactor: remove create1 and create2 functions
AlexD10S 38dac39
refactor: clean up unnecesary code
AlexD10S dcd0693
chore: upgrade polkadotjs
AlexD10S a7d571c
Merge branch 'master' into refactor/instantiated-event
AlexD10S 942be4c
chore: update yarn.lock
AlexD10S File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -8,16 +8,14 @@ import { Button, Buttons } from '../common/Button'; | |
| import { printBN } from 'lib/bn'; | ||
| import { createInstantiateTx } from 'services/chain'; | ||
| import { SubmittableResult } from 'types'; | ||
| import { useApi, useInstantiate, useTransactions, useVersion } from 'ui/contexts'; | ||
| import { useApi, useInstantiate, useTransactions } from 'ui/contexts'; | ||
| import { useNewContract } from 'ui/hooks'; | ||
| import { transformUserInput } from 'lib/callOptions'; | ||
|
|
||
| export function Step3() { | ||
| const { codeHash: codeHashUrlParam } = useParams<{ codeHash: string }>(); | ||
| const { data, step, setStep } = useInstantiate(); | ||
| const { api } = useApi(); | ||
| const { version } = useVersion(); | ||
| const { accountId, value, metadata, gasLimit, name, constructorIndex, salt } = data; | ||
| const { accountId, value, metadata, gasLimit, name, constructorIndex } = data; | ||
| const { queue, process, txs, dismiss } = useTransactions(); | ||
| const [txId, setTxId] = useState<number>(0); | ||
| const onSuccess = useNewContract(); | ||
|
|
@@ -35,27 +33,7 @@ export function Step3() { | |
| extrinsic: tx, | ||
| accountId: data.accountId, | ||
| onSuccess: result => { | ||
| if (version !== 'v6') { | ||
| return onSuccess(result); | ||
| } | ||
| const constructor = metadata?.findConstructor(constructorIndex); | ||
| const transformed = transformUserInput( | ||
| api.registry, | ||
| constructor?.args || [], | ||
| data.argValues, | ||
| ); | ||
| const inputData = constructor?.toU8a(transformed).slice(1); // exclude the first byte (the length byte) | ||
| // Pass the contract data and extrinsic to onSuccess | ||
| // @ts-ignore | ||
| return onSuccess({ | ||
| ...result, | ||
| contractData: { | ||
| salt: salt?.toString() || '', | ||
| data: inputData || new Uint8Array(), | ||
| // @ts-ignore | ||
| code: metadata?.json.source.contract_binary, | ||
| }, | ||
| }); | ||
| return onSuccess(result); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same approach now for ink! v5 and ink! v6: get the address from the instantiated event |
||
| }, | ||
| isValid, | ||
| }); | ||
|
|
||
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Removed these functions as there is no need to keep them anymore.