Skip to content
Merged
Show file tree
Hide file tree
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
19 changes: 3 additions & 16 deletions packages/api-contract/src/base/Blueprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,9 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
this.abi.findConstructor(constructorOrId).toU8a(params),
encodeSalt(salt)
).withResultTransform((result: ISubmittableResult) =>
new BlueprintSubmittableResult(result,
this._isRevive
? (
(result.status.isInBlock || result.status.isFinalized)
? new Contract<ApiType>(
this.api,
this.abi,
// your fixed address for revive deployments
this.registry.createType('AccountId', '0x'),
this._decorateMethod
)
: undefined
)
: applyOnEvent(result, ['Instantiated'], ([record]: EventRecord[]) =>
new Contract<ApiType>(this.api, this.abi, record.event.data[1] as AccountId, this._decorateMethod), this._isRevive
)
new BlueprintSubmittableResult(result, applyOnEvent(result, ['Instantiated'], ([record]: EventRecord[]) =>
new Contract<ApiType>(this.api, this.abi, record.event.data[1] as AccountId, this._decorateMethod), this._isRevive
)
)
);
};
Expand Down
19 changes: 17 additions & 2 deletions packages/api-contract/src/base/Code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,23 @@ export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
).withResultTransform((result: ISubmittableResult) =>
new CodeSubmittableResult(
result,
new Blueprint<ApiType>(this.api, this.abi, this.abi.info.source.hash, this._decorateMethod),
new Contract<ApiType>(this.api, this.abi, '0x', this._decorateMethod)
...(applyOnEvent(result, ['Instantiated'], (records: EventRecord[]) =>
records.reduce<[Blueprint<ApiType> | undefined, Contract<ApiType> | undefined]>(
([blueprint, contract], { event }) =>
this.api.events.revive['Instantiated'].is(event)
? [
blueprint,
new Contract<ApiType>(
this.api,
this.abi,
(event as unknown as { data: [Codec, AccountId] }).data[1],
this._decorateMethod
)
]
: [blueprint, contract],
[undefined, undefined]
), this._isRevive
) || [undefined, undefined])
)
);
}
Expand Down