Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmychu0807 committed Oct 26, 2021
1 parent 2637d8f commit 3810fd7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 13 additions & 1 deletion packages/page-instantiate/src/NewFromCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,21 @@ function NewFromCode ({ className }: Props): React.ReactElement<Props> | null {

try {
const { identifier } = abi?.constructors[constructorIndex] || '';
const call = `${identifier[0].toLowerCase()}${identifier.slice(1)}`;

// Fix: If param conforms to this shape, extract the `value` from
// `{ isValid: bool, value: obj }`.
const tParams = params.map(param => param.value
? (param.isValid ? param.value : null)
: param
);

contract = code && identifier && endowment
? code.tx[`${identifier[0].toLowerCase()}${identifier.slice(1)}`]({ gasLimit: weight, salt: withSalt ? salt : null, value: endowment }, ...params)
? code.tx[`${call}`]({
gasLimit: weight,
salt: withSalt ? salt : null,
value: endowment
}, ...tParams)
: null;

setUploadTx(() => [contract, error]);
Expand Down
4 changes: 3 additions & 1 deletion packages/react-components/src/Params/values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ export function createValue (registry: Registry, param: { type: TypeDef }): RawP
}

export default function createValues (registry: Registry, params: { type: TypeDef }[]): RawParam[] {
return params.map((param) => createValue(registry, param));
return params
? params.map(param => createValue(registry, param))
: []
}

0 comments on commit 3810fd7

Please sign in to comment.