Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

feat: fix typing for inheritence in manifest builder #50

Merged
merged 2 commits into from
Apr 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 24 additions & 33 deletions lib/manifest-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ export class ManifestBuilder {
* @param bucketName The name of the new bucket
* @returns
*/
takeFromWorktop(
resourceAddress: AddressString,
bucketName: string
): ManifestBuilder {
takeFromWorktop(resourceAddress: AddressString, bucketName: string): this {
this.instructions.push(
`TAKE_FROM_WORKTOP ${Address(resourceAddress)} ${Bucket(bucketName)};`
)
Expand All @@ -62,7 +59,7 @@ export class ManifestBuilder {
amount: number,
resourceAddresses: AddressString,
bucketName: string
): ManifestBuilder {
): this {
this.instructions.push(
`TAKE_FROM_WORKTOP_BY_AMOUNT ${Decimal(amount)} ${Address(
resourceAddresses
Expand All @@ -84,7 +81,7 @@ export class ManifestBuilder {
nonFungibleLocalIds: NonFungibleLocalIdString[],
resourceAddress: AddressString,
bucketName: string
): ManifestBuilder {
): this {
let temp = nonFungibleLocalIds
.map(function (id) {
return 'NonFungibleLocalId("' + id + '")'
Expand Down Expand Up @@ -116,7 +113,7 @@ export class ManifestBuilder {
* @param resourceAddress The resource address
* @returns
*/
assertWorktopContains(resourceAddress: AddressString): ManifestBuilder {
assertWorktopContains(resourceAddress: AddressString): this {
this.instructions.push(
`ASSERT_WORKTOP_CONTAINS ${Address(resourceAddress)};`
)
Expand All @@ -133,7 +130,7 @@ export class ManifestBuilder {
assertWorktopContainsByAmount(
amount: number,
resourceAddress: AddressString
): ManifestBuilder {
): this {
this.instructions.push(
`ASSERT_WORKTOP_CONTAINS_BY_AMOUNT ${Decimal(amount)} ${Address(
resourceAddress
Expand All @@ -152,7 +149,7 @@ export class ManifestBuilder {
assertWorktopContainsByIds(
nonFungibleLocalIds: NonFungibleLocalIdString[],
resourceAddress: AddressString
): ManifestBuilder {
): this {
let temp = nonFungibleLocalIds
.map(function (id) {
return 'NonFungibleLocalId("' + id + '")'
Expand All @@ -172,7 +169,7 @@ export class ManifestBuilder {
* @param proofName The name of the new proof
* @returns
*/
popFromAuthZone(proofName: string): ManifestBuilder {
popFromAuthZone(proofName: string): this {
this.instructions.push(`POP_FROM_AUTH_ZONE ${Proof(proofName)};`)
this.proofs.set(proofName, this.id_allocator++)
return this
Expand All @@ -184,7 +181,7 @@ export class ManifestBuilder {
* @param proofName The proof name
* @returns
*/
pushToAuthZone(proofName: string): ManifestBuilder {
pushToAuthZone(proofName: string): this {
this.instructions.push(`PUSH_TO_AUTH_ZONE ${Proof(proofName)};`)
return this
}
Expand All @@ -194,7 +191,7 @@ export class ManifestBuilder {
*
* @returns
*/
clearAuthZone(): ManifestBuilder {
clearAuthZone(): this {
this.instructions.push('CLEAR_AUTH_ZONE;')
return this
}
Expand All @@ -209,7 +206,7 @@ export class ManifestBuilder {
createProofFromAuthZone(
resourceAddress: AddressString,
proofName: string
): ManifestBuilder {
): this {
this.instructions.push(
`CREATE_PROOF_FROM_AUTH_ZONE ${Address(resourceAddress)} ${Proof(
proofName
Expand All @@ -231,7 +228,7 @@ export class ManifestBuilder {
amount: number,
resourceAddress: AddressString,
proofName: string
): ManifestBuilder {
): this {
this.instructions.push(
`CREATE_PROOF_FROM_AUTH_ZONE_BY_AMOUNT ${Decimal(amount)} ${Address(
resourceAddress
Expand All @@ -253,7 +250,7 @@ export class ManifestBuilder {
nonFungibleLocalIds: NonFungibleLocalIdString[],
resourceAddress: AddressString,
proofName: string
): ManifestBuilder {
): this {
let temp = nonFungibleLocalIds
.map(function (id) {
return 'NonFungibleLocalId("' + id + '")'
Expand All @@ -275,10 +272,7 @@ export class ManifestBuilder {
* @param proofName The name of the new proof
* @returns
*/
createProofFromBucket(
bucketName: string,
proofName: string
): ManifestBuilder {
createProofFromBucket(bucketName: string, proofName: string): this {
this.instructions.push(
`CREATE_PROOF_FROM_BUCKET ${Bucket(bucketName)} ${Proof(proofName)};`
)
Expand All @@ -293,7 +287,7 @@ export class ManifestBuilder {
* @param cloneName The clone proof name
* @returns
*/
cloneProof(proofName: string, cloneName: string): ManifestBuilder {
cloneProof(proofName: string, cloneName: string): this {
this.instructions.push(
`CLONE_PROOF ${Proof(proofName)} ${Proof(cloneName)};`
)
Expand All @@ -307,7 +301,7 @@ export class ManifestBuilder {
* @param proofName The proof name
* @returns
*/
dropProof(proofName: string): ManifestBuilder {
dropProof(proofName: string): this {
this.instructions.push(`DROP_PROOF ${Proof(proofName)};`)
return this
}
Expand All @@ -325,7 +319,7 @@ export class ManifestBuilder {
blueprintName: string,
functionName: string,
args: string[]
): ManifestBuilder {
): this {
this.instructions.push(
`CALL_FUNCTION ${Address(
packageAddress
Expand All @@ -346,7 +340,7 @@ export class ManifestBuilder {
componentAddress: AddressString,
methodName: string,
args: string[]
): ManifestBuilder {
): this {
this.instructions.push(
`CALL_METHOD ${Address(componentAddress)} "${methodName}" ${args.join(
' '
Expand All @@ -362,10 +356,7 @@ export class ManifestBuilder {
* @param amount The amount to mint
* @returns
*/
mintFungible(
resourceAddress: AddressString,
amount: number
): ManifestBuilder {
mintFungible(resourceAddress: AddressString, amount: number): this {
this.instructions.push(
`MINT_FUNGIBLE ${Address(resourceAddress)} ${Decimal(amount)};`
)
Expand All @@ -384,7 +375,7 @@ export class ManifestBuilder {
accountAddress: AddressString,
resourceAddress: AddressString,
amount: number
): ManifestBuilder {
): this {
this.instructions.push(
`CALL_METHOD ${Address(accountAddress)} "withdraw" ${Address(
resourceAddress
Expand All @@ -405,7 +396,7 @@ export class ManifestBuilder {
accountAddress: AddressString,
resourceAddress: AddressString,
nonFungibleLocalIds: NonFungibleLocalIdString[]
): ManifestBuilder {
): this {
let temp = nonFungibleLocalIds
.map(function (id) {
return 'NonFungibleLocalId("' + id + '")'
Expand All @@ -431,7 +422,7 @@ export class ManifestBuilder {
createProofFromAccount(
accountAddress: AddressString,
resourceAddress: AddressString
): ManifestBuilder {
): this {
this.instructions.push(
`CALL_METHOD ${Address(accountAddress)} "create_proof" ${Address(
resourceAddress
Expand All @@ -452,7 +443,7 @@ export class ManifestBuilder {
accountAddress: AddressString,
resourceAddress: AddressString,
amount: number
): ManifestBuilder {
): this {
this.instructions.push(
`CALL_METHOD ${Address(
accountAddress
Expand All @@ -475,7 +466,7 @@ export class ManifestBuilder {
accountAddress: AddressString,
resourceAddress: AddressString,
nonFungibleLocalIds: NonFungibleLocalIdString[]
): ManifestBuilder {
): this {
let temp = nonFungibleLocalIds
.map(function (id) {
return 'NonFungibleLocalId("' + id + '")'
Expand All @@ -496,7 +487,7 @@ export class ManifestBuilder {
* @param args The instruction arguments
* @returns
*/
instruction(name: string, args: string[]): ManifestBuilder {
instruction(name: string, args: string[]): this {
this.instructions.push(`${name} ${args.join(' ')};`)
return this
}
Expand Down