Add DTK tutorial for creating an invite link#2289
Add DTK tutorial for creating an invite link#2289alexandratran merged 21 commits intofeat/v0.13-devfrom
Conversation
useSDK is now modified and connect, terminate options have moved to sdk object inside useSDK function Co-authored-by: Mohammad Shahbaz Alam <shahbaz17@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Signed-off-by: bgravenorst <byron.gravenorst@consensys.net>
* Edit the React builder component. Signed-off-by: bgravenorst <byron.gravenorst@consensys.net> * Typo. Signed-off-by: bgravenorst <byron.gravenorst@consensys.net> --------- Signed-off-by: bgravenorst <byron.gravenorst@consensys.net>
useSDK is now modified and connect, terminate options have moved to sdk object inside useSDK function Co-authored-by: Mohammad Shahbaz Alam <shahbaz17@users.noreply.github.com>
Signed-off-by: bgravenorst <byron.gravenorst@consensys.net>
* Edit the React builder component. Signed-off-by: bgravenorst <byron.gravenorst@consensys.net> * Typo. Signed-off-by: bgravenorst <byron.gravenorst@consensys.net> --------- Signed-off-by: bgravenorst <byron.gravenorst@consensys.net>
…amask-docs into 2209-referral-link-tutorial # Conflicts: # src/pages/tutorials/create-custom-caveat-enforcer.md
bgravenorst
left a comment
There was a problem hiding this comment.
LGTM, some minor feedback added.
| import { Implementation, toMetaMaskSmartAccount } from '@metamask/delegation-toolkit'; | ||
| import { privateKeyToAccount } from 'viem/accounts'; | ||
|
|
||
| const account = privateKeyToAccount('0x...'); |
There was a problem hiding this comment.
This should use wagmi hooks.
There was a problem hiding this comment.
Updated. Question: do we still need to create the Viem Public Client in Step 2.1. if we're using the Wagmi usePublicClient in this step? It looks like in the Viem Public Client isn't used for the Bundler Client in the gator-example.
| Encode the delegation into a shareable URL: | ||
|
|
||
| ```tsx | ||
| export function encodeDelegation(delegation: Delegation): string { |
There was a problem hiding this comment.
imports are missing for this step.
| const urlParams = new URLSearchParams(window.location.search); | ||
| const encodedDelegation = urlParams.get('delegation'); | ||
|
|
||
| export function decodeDelegation(encodedDelegation: string): Delegation { | ||
| const decodedDelegationJson = Buffer.from(encodedDelegation, 'base64').toString('utf-8'); | ||
| return JSON.parse(decodedDelegationJson) as Delegation; | ||
| } | ||
|
|
||
| const decodedDelegation = decodeDelegation(encodedDelegation); |
There was a problem hiding this comment.
same, imports are missing. specially for the dtk functions/ classes
There was a problem hiding this comment.
Is there anything missing besides Delegation?
| [Redeem the delegation](/delegation-toolkit/development/guides/delegation/execute-on-smart-accounts-behalf/#7-redeem-the-delegation) by submitting a user operation from the smart account created in [Step 3](#3-create-a-smart-account) to the `DelegationManager` contract. | ||
| The delegation manager validates the delegation and executes delegated actions. | ||
| In this case, the invitee can spend up to 0.001 ETH when using your dapp. |
There was a problem hiding this comment.
Maybe we should change the words a bit, and say account be deployed for the first time users, or something? Invitee won't go through the step 3.
|
|
||
| const delegations = [decodedDelegation]; | ||
|
|
||
| const executions = createExecution({ target: zeroAddress }); |
There was a problem hiding this comment.
This is not correct, this will basically do a 0 value transfer to zeroAddress. You can check this file.
https://github.com/MetaMask/gator-examples/blob/c391305074d1d3faa61e65f3994828bb4f369022/examples/invitation-link-example/src/utils/delegationUtils.ts
| Create a [Viem Public Client](https://viem.sh/docs/clients/public) using Viem's `createPublicClient` function. | ||
| You will configure a Bundler Client with the Public Client, which you can use to query the signer's account state and interact with the blockchain network. | ||
|
|
||
| ```tsx | ||
| import { createPublicClient, http } from 'viem'; | ||
| import { sepolia as chain } from 'viem/chains'; | ||
|
|
||
| const publicClient = createPublicClient({ | ||
| chain, | ||
| transport: http(), | ||
| }); | ||
| ``` |
There was a problem hiding this comment.
I think you also mentioned about getting this from Wagmi which was good point, this can be skipped and we can use wagmi hooks instead.
* Add delegation scopes guide * add delegation scopes guide * minor edits and rename files * add delegation scopes to manual sidebar * restructure and edit * edit to include scopes in guides * address reviewer comments --------- Co-authored-by: “AyushBherwani1998” <“ayush.bherwani1998@gmail.com”> Co-authored-by: Alexandra Tran <alexandratran@protonmail.com> * Update dtk tutorial for v0.13 * Update creating delegation references for v0.13 * Minor DTK fixes (#2277) * Minor DTK fixes * Apply suggestions from code review Co-authored-by: Ayush Bherwani <ayush.bherwani1998@gmail.com> --------- Co-authored-by: Ayush Bherwani <ayush.bherwani1998@gmail.com> * Fix broken links (#2278) * update execute on smart accounts behalf guide * add parameters in delegation scopes * update reference docs * update guide: execute-on-smart-accounts-behalf * Apply suggestions from code review Co-authored-by: Alexandra Carrillo <12214231+alexandratran@users.noreply.github.com> --------- Co-authored-by: Alexandra Carrillo <12214231+alexandratran@users.noreply.github.com> Co-authored-by: AyushBherwani1998 <“ayush.bherwani1998@gmail.com”> * Update caveats to use new declarative format * update execution modes * update parametes of caveats to new caveat configs * update caveats api reference to new declarative format * Apply suggestions from code review Co-authored-by: Alexandra Carrillo <12214231+alexandratran@users.noreply.github.com> * improve docs --------- Co-authored-by: AyushBherwani1998 <“ayush.bherwani1998@gmail.com”> Co-authored-by: Alexandra Carrillo <12214231+alexandratran@users.noreply.github.com> * Adds guide: Check the delegation state * add check delegation state guide * fix typos * minor edits --------- Co-authored-by: AyushBherwani1998 <“ayush.bherwani1998@gmail.com”> Co-authored-by: Alexandra Tran <alexandratran@protonmail.com> * Adds guide: Constrain a scope * add constrain a scope documentation * edit guide and fix links * minor edits --------- Co-authored-by: AyushBherwani1998 <“ayush.bherwani1998@gmail.com”> Co-authored-by: Alexandra Tran <alexandratran@protonmail.com> * Update reference section * restructure reference docs * add support for caveat enforcer client reference * add delegation api index page, fix links, adjust toc style * revert toc code font size --------- Co-authored-by: AyushBherwani1998 <“ayush.bherwani1998@gmail.com”> Co-authored-by: Alexandra Tran <alexandratran@protonmail.com> * Update docs to use signer * update to use signer * revert the ref changes * apply reviewer suggestion Co-authored-by: Alexandra Carrillo <12214231+alexandratran@users.noreply.github.com> --------- Co-authored-by: AyushBherwani1998 <“ayush.bherwani1998@gmail.com”> Co-authored-by: Alexandra Carrillo <12214231+alexandratran@users.noreply.github.com> * Add DTK tutorial for creating an invite link (#2289) * Fix typos Co-authored-by: AyushBherwani1998 <“ayush.bherwani1998@gmail.com”> * Update react-native.md (#2225) useSDK is now modified and connect, terminate options have moved to sdk object inside useSDK function Co-authored-by: Mohammad Shahbaz Alam <shahbaz17@users.noreply.github.com> * Add DTK tutorial for creating an invite link * Edit the Angular SDK content. (#2287) Signed-off-by: bgravenorst <byron.gravenorst@consensys.net> * Fix deeplink urls (#2293) * Edit the embedded wallets React builder component. (#2292) * Edit the React builder component. Signed-off-by: bgravenorst <byron.gravenorst@consensys.net> * Typo. Signed-off-by: bgravenorst <byron.gravenorst@consensys.net> --------- Signed-off-by: bgravenorst <byron.gravenorst@consensys.net> * update tutorial * Add DTK tutorial for creating an invite link * Update react-native.md (#2225) useSDK is now modified and connect, terminate options have moved to sdk object inside useSDK function Co-authored-by: Mohammad Shahbaz Alam <shahbaz17@users.noreply.github.com> * Edit the Angular SDK content. (#2287) Signed-off-by: bgravenorst <byron.gravenorst@consensys.net> * Fix deeplink urls (#2293) * update tutorial * Edit the embedded wallets React builder component. (#2292) * Edit the React builder component. Signed-off-by: bgravenorst <byron.gravenorst@consensys.net> * Typo. Signed-off-by: bgravenorst <byron.gravenorst@consensys.net> --------- Signed-off-by: bgravenorst <byron.gravenorst@consensys.net> * add wagmi step and adjust headings * address reviewer comments * address reviewer comments * minor edits --------- Signed-off-by: bgravenorst <byron.gravenorst@consensys.net> Co-authored-by: Ayush Bherwani <ayush.bherwani1998@gmail.com> Co-authored-by: AyushBherwani1998 <“ayush.bherwani1998@gmail.com”> Co-authored-by: Arnav Chhabra <65032719+Halleys123@users.noreply.github.com> Co-authored-by: Mohammad Shahbaz Alam <shahbaz17@users.noreply.github.com> Co-authored-by: Byron Gravenorst <50852695+bgravenorst@users.noreply.github.com> * revert the ew changes * revert ew change * v0.13 changes * v0.13 changes * Apply suggestions from code review Co-authored-by: Alexandra Carrillo <12214231+alexandratran@users.noreply.github.com> --------- Co-authored-by: Ayush Bherwani <“ayush.bherwani1998@gmail.com”> Co-authored-by: Alexandra Carrillo <12214231+alexandratran@users.noreply.github.com> * minor edits * remove todo * use disallows instead of disables * remove 7715 card from intro page * improve delegation scope ref description * add getMultiTokenPeriodEnforcerAvailableAmount action --------- Signed-off-by: bgravenorst <byron.gravenorst@consensys.net> Co-authored-by: “AyushBherwani1998” <“ayush.bherwani1998@gmail.com”> Co-authored-by: Alexandra Tran <alexandratran@protonmail.com> Co-authored-by: Alexandra Carrillo <12214231+alexandratran@users.noreply.github.com> Co-authored-by: Arnav Chhabra <65032719+Halleys123@users.noreply.github.com> Co-authored-by: Mohammad Shahbaz Alam <shahbaz17@users.noreply.github.com> Co-authored-by: Byron Gravenorst <50852695+bgravenorst@users.noreply.github.com>
Description
Add DTK tutorial for creating an invite link.
Issue(s) fixed
Fixes #2209
Preview
https://metamask-docs-i5mlyvk77-consensys-ddffed67.vercel.app/tutorials/create-invite-link/
Checklist