-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #194 from MeshJS/feature-update/mesh-tx-builder-st…
…aking Feature update/mesh tx builder staking
- Loading branch information
Showing
16 changed files
with
465 additions
and
84 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
packages/demo/components/pages/apis/transaction/builder/delegateStakeCertificate.tsx
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,28 @@ | ||
import Section from '../../../../common/section'; | ||
import Codeblock from '../../../../ui/codeblock'; | ||
|
||
export default function DeregisterCertificate() { | ||
return ( | ||
<Section | ||
sidebarTo="delegateStakeCertificate" | ||
header="Delegate Stake to a Pool" | ||
contentFn={Content()} | ||
/> | ||
); | ||
} | ||
|
||
function Content() { | ||
let code = `mesh | ||
.delegateStakeCertificate(stakeKeyHash: string, poolId: string)`; | ||
|
||
return ( | ||
<> | ||
<p> | ||
Use <code>.delegateStakeCertificate()</code> to delegate a stake to a | ||
pool: | ||
</p> | ||
|
||
<Codeblock data={code} isJson={false} /> | ||
</> | ||
); | ||
} |
28 changes: 28 additions & 0 deletions
28
packages/demo/components/pages/apis/transaction/builder/deregisterCertificate.tsx
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,28 @@ | ||
import Section from '../../../../common/section'; | ||
import Codeblock from '../../../../ui/codeblock'; | ||
|
||
export default function DeregisterCertificate() { | ||
return ( | ||
<Section | ||
sidebarTo="deregisterCertificate" | ||
header="Deregister Stake Certificate" | ||
contentFn={Content()} | ||
/> | ||
); | ||
} | ||
|
||
function Content() { | ||
let code = `mesh | ||
.deregisterStakeCertificate(stakeKeyHash: string)`; | ||
|
||
return ( | ||
<> | ||
<p> | ||
Use <code>.deregisterStakeCertificate()</code> to deregister a stake | ||
certificate: | ||
</p> | ||
|
||
<Codeblock data={code} isJson={false} /> | ||
</> | ||
); | ||
} |
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
28 changes: 28 additions & 0 deletions
28
packages/demo/components/pages/apis/transaction/builder/registerCertificate.tsx
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,28 @@ | ||
import Section from '../../../../common/section'; | ||
import Codeblock from '../../../../ui/codeblock'; | ||
|
||
export default function RegisterCertificate() { | ||
return ( | ||
<Section | ||
sidebarTo="registerCertificate" | ||
header="Register Stake Certificate" | ||
contentFn={Content()} | ||
/> | ||
); | ||
} | ||
|
||
function Content() { | ||
let code = `mesh | ||
.registerStakeCertificate(stakeKeyHash: string)`; | ||
|
||
return ( | ||
<> | ||
<p> | ||
Use <code>.registerStakeCertificate()</code> to register a stake | ||
certificate: | ||
</p> | ||
|
||
<Codeblock data={code} isJson={false} /> | ||
</> | ||
); | ||
} |
28 changes: 28 additions & 0 deletions
28
packages/demo/components/pages/apis/transaction/builder/registerPoolCertificate.tsx
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,28 @@ | ||
import Section from '../../../../common/section'; | ||
import Codeblock from '../../../../ui/codeblock'; | ||
|
||
export default function RegisterPoolCertificate() { | ||
return ( | ||
<Section | ||
sidebarTo="registerPoolCertificate" | ||
header="Register Pool Certificate" | ||
contentFn={Content()} | ||
/> | ||
); | ||
} | ||
|
||
function Content() { | ||
let code = `mesh | ||
.registerPoolCertificate(poolParams: PoolParams)`; | ||
|
||
return ( | ||
<> | ||
<p> | ||
Use <code>.registerPoolCertificate()</code> to register a pool | ||
certificate: | ||
</p> | ||
|
||
<Codeblock data={code} isJson={false} /> | ||
</> | ||
); | ||
} |
27 changes: 27 additions & 0 deletions
27
packages/demo/components/pages/apis/transaction/builder/retirePoolCertificate.tsx
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,27 @@ | ||
import Section from '../../../../common/section'; | ||
import Codeblock from '../../../../ui/codeblock'; | ||
|
||
export default function RetirePoolCertificate() { | ||
return ( | ||
<Section | ||
sidebarTo="retirePoolCertificate" | ||
header="Retire Pool Certificate" | ||
contentFn={Content()} | ||
/> | ||
); | ||
} | ||
|
||
function Content() { | ||
let code = `mesh | ||
.retirePoolCertificate(poolId: string, epoch: number)`; | ||
|
||
return ( | ||
<> | ||
<p> | ||
Use <code>.retirePoolCertificate()</code> to retire a pool certificate: | ||
</p> | ||
|
||
<Codeblock data={code} isJson={false} /> | ||
</> | ||
); | ||
} |
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
39 changes: 39 additions & 0 deletions
39
packages/demo/components/pages/apis/transaction/builderExample/staking.tsx
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,39 @@ | ||
import Section from '../../../../common/section'; | ||
import Codeblock from '../../../../ui/codeblock'; | ||
|
||
export default function Staking() { | ||
return ( | ||
<Section | ||
sidebarTo="staking" | ||
header="Build a transaction to (register stake certificate and) delegate stake to a pool" | ||
contentFn={Content()} | ||
/> | ||
); | ||
} | ||
|
||
function Content() { | ||
const codeSnippet = `const usedAddress = await wallet.getUnusedAddresses(); | ||
const { stakeCredential } = serializeBech32Address(usedAddress[0]); | ||
await mesh | ||
.txIn(txInHash, txInId) | ||
.registerStakeCertificate(stakeCredential) // Skip this line if you are not staking for the first time | ||
.delegateStakeCertificate( | ||
stakeCredential, | ||
'poolxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' | ||
) | ||
.changeAddress(changeAddress) | ||
.complete(); | ||
const signedTx = mesh.completeSigning()`; | ||
|
||
return ( | ||
<> | ||
<p> | ||
The following shows a simple example of building a transaction to | ||
(register stake certificate and) delegate stake to a pool for the first | ||
time. | ||
</p> | ||
<Codeblock data={codeSnippet} isJson={false} /> | ||
</> | ||
); | ||
} |
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.