-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(txwrapper): support gearVoucher pallet (#1570)
- Loading branch information
1 parent
e22669f
commit 8c604f3
Showing
23 changed files
with
755 additions
and
448 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
node_modules/ | ||
**/.DS_Store | ||
.idea | ||
.yarn/* | ||
**/.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
|
This file was deleted.
Oops, something went wrong.
Binary file not shown.
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
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
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,54 @@ | ||
import { Args, BaseTxInfo, defineMethod, OptionsWithMeta, UnsignedTransaction } from '@substrate/txwrapper-core'; | ||
import { SendMessageArgs } from '../gear/sendMessage'; | ||
import { SendReplyArgs } from '../gear/sendReply'; | ||
import { UploadCodeArgs } from '../gear/uploadCode'; | ||
import { DeclineArgs } from './decline'; | ||
|
||
export interface SendMessageWithVoucher extends Args { | ||
SendMessage: SendMessageArgs; | ||
} | ||
|
||
export interface SendReplyWithVoucher extends Args { | ||
SendReply: SendReplyArgs; | ||
} | ||
|
||
export interface UploadCodeWithVoucher extends Args { | ||
UploadCode: UploadCodeArgs; | ||
} | ||
|
||
export interface DeclineVoucherWithVoucher extends Args { | ||
DeclineVoucher: DeclineArgs; | ||
} | ||
|
||
export interface CallArgs extends Args { | ||
/** | ||
* The id of the voucher to be used. | ||
*/ | ||
voucherId: string; | ||
|
||
/** | ||
* Call options | ||
*/ | ||
call: SendMessageWithVoucher | SendReplyWithVoucher | UploadCodeWithVoucher | DeclineVoucherWithVoucher; | ||
} | ||
|
||
/** | ||
* Construct a createProgram transaction offline. | ||
* | ||
* @param args - Arguments specific to this method. | ||
* @param info - Information required to construct the transaction. | ||
* @param options - Registry and metadata used for constructing the method. | ||
*/ | ||
export function call(args: CallArgs, info: BaseTxInfo, options: OptionsWithMeta): UnsignedTransaction { | ||
return defineMethod( | ||
{ | ||
method: { | ||
args, | ||
name: 'call', | ||
pallet: 'gearVoucher', | ||
}, | ||
...info, | ||
}, | ||
options, | ||
); | ||
} |
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 { Args, BaseTxInfo, defineMethod, OptionsWithMeta, UnsignedTransaction } from '@substrate/txwrapper-core'; | ||
|
||
export interface DeclineArgs extends Args { | ||
/** | ||
* The id of the voucher to be declined. | ||
*/ | ||
voucherId: string; | ||
} | ||
|
||
/** | ||
* Construct a decline voucher transaction offline. | ||
* | ||
* @param args - Arguments specific to this method. | ||
* @param info - Information required to construct the transaction. | ||
* @param options - Registry and metadata used for constructing the method. | ||
*/ | ||
export function decline(args: DeclineArgs, info: BaseTxInfo, options: OptionsWithMeta): UnsignedTransaction { | ||
return defineMethod( | ||
{ | ||
method: { | ||
args, | ||
name: 'decline', | ||
pallet: 'gearVoucher', | ||
}, | ||
...info, | ||
}, | ||
options, | ||
); | ||
} |
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,5 @@ | ||
export * from './call'; | ||
export * from './decline'; | ||
export * from './issue'; | ||
export * from './revoke'; | ||
export * from './update'; |
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,49 @@ | ||
import { Args, BaseTxInfo, defineMethod, OptionsWithMeta, UnsignedTransaction } from '@substrate/txwrapper-core'; | ||
|
||
export interface IssueArgs extends Args { | ||
/** | ||
* The voucher holder account id. | ||
*/ | ||
spender: string; | ||
|
||
/** | ||
* The voucher amount. | ||
*/ | ||
value: string | number; | ||
|
||
/** | ||
* The number of the block until which the voucher is valid. If not specified, the voucher is valid in `api.voucher.minDuration` blocks. | ||
*/ | ||
duration: string | number; | ||
|
||
/** | ||
* The list of programs that the voucher can be used for. If not specified, the voucher can be used for any program. | ||
*/ | ||
programs: string[] | null; | ||
|
||
/** | ||
* Whether the voucher can be used for uploading code. | ||
*/ | ||
codeUploading: boolean; | ||
} | ||
|
||
/** | ||
* Construct a decline voucher transaction offline. | ||
* | ||
* @param args - Arguments specific to this method. | ||
* @param info - Information required to construct the transaction. | ||
* @param options - Registry and metadata used for constructing the method. | ||
*/ | ||
export function issue(args: IssueArgs, info: BaseTxInfo, options: OptionsWithMeta): UnsignedTransaction { | ||
return defineMethod( | ||
{ | ||
method: { | ||
args, | ||
name: 'issue', | ||
pallet: 'gearVoucher', | ||
}, | ||
...info, | ||
}, | ||
options, | ||
); | ||
} |
22 changes: 9 additions & 13 deletions
22
...rapper/src/methods/gear/payProgramRent.ts → ...wrapper/src/methods/gearVoucher/revoke.ts
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,59 @@ | ||
import { Args, BaseTxInfo, defineMethod, OptionsWithMeta, UnsignedTransaction } from '@substrate/txwrapper-core'; | ||
|
||
export interface UpdateArgs extends Args { | ||
/** | ||
* The voucher holder account id. | ||
*/ | ||
spender: string; | ||
|
||
/** | ||
* The id of the voucher to be revoked. | ||
*/ | ||
voucherId: string; | ||
|
||
/** | ||
* The new voucher owner. | ||
*/ | ||
moveOwnership: string | null; | ||
|
||
/** | ||
* The new voucher balance. | ||
*/ | ||
balanceTopUp: number | string | null; | ||
|
||
/** | ||
* Append new programs to the voucher. | ||
*/ | ||
appendPrograms: string[] | null; | ||
|
||
/** | ||
* Enable or disable code uploading. | ||
*/ | ||
codeUploading: boolean | null; | ||
|
||
/** | ||
* Prolong the duration of th voucher validity. | ||
*/ | ||
prolongDuration: number | null; | ||
} | ||
|
||
/** | ||
* Construct a decline voucher transaction offline. | ||
* | ||
* @param args - Arguments specific to this method. | ||
* @param info - Information required to construct the transaction. | ||
* @param options - Registry and metadata used for constructing the method. | ||
*/ | ||
export function update(args: UpdateArgs, info: BaseTxInfo, options: OptionsWithMeta): UnsignedTransaction { | ||
return defineMethod( | ||
{ | ||
method: { | ||
args, | ||
name: 'update', | ||
pallet: 'gearVoucher', | ||
}, | ||
...info, | ||
}, | ||
options, | ||
); | ||
} |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * as gear from './gear'; | ||
export * as gearVoucher from './gearVoucher'; |
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1 +1 @@ | ||
export default 160; | ||
export default 1310; |
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.