Skip to content

Commit

Permalink
Merge pull request #57 from kaleido-io/numbers
Browse files Browse the repository at this point in the history
Pass all token numbers as strings
  • Loading branch information
awrichar authored Apr 20, 2022
2 parents 5b8d25c + a1b562d commit f8c8603
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 35 deletions.
14 changes: 7 additions & 7 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"homepage": "https://github.com/hyperledger/firefly-sandbox#readme",
"dependencies": {
"@hyperledger/firefly-sdk": "^0.1.0-alpha.5",
"@hyperledger/firefly-sdk": "^0.1.0-alpha.8",
"body-parser": "^1.20.0",
"class-transformer": "^0.3.1",
"class-validator": "^0.12.2",
Expand Down
10 changes: 5 additions & 5 deletions server/src/controllers/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class ContractsController {
? await firefly.generateContractInterface({
name: body.name,
version: body.version,
input: { abi: body.schema } as any,
input: { abi: body.schema },
})
: body.schema;
const result = await firefly.createContractInterface(ffi);
Expand All @@ -64,7 +64,7 @@ export class ContractsController {
},
location: {
address: body.address,
} as any,
},
});
return { type: 'message', id: api.message };
}
Expand All @@ -84,7 +84,7 @@ export class ContractsController {
const apis = await firefly.getContractAPIs();
return apis.map((api) => ({
name: api.name,
address: (api.location as any)?.address,
address: api.location?.address,
urls: api.urls,
}));
}
Expand All @@ -100,7 +100,7 @@ export class ContractsController {
const ffi = await firefly.getContractInterface(api.interface.id, true);
return {
name: api.name,
address: (api.location as any)?.address,
address: api.location?.address,
urls: api.urls,
events: ffi.events?.map((e) => ({ pathname: e.pathname })),
};
Expand All @@ -119,7 +119,7 @@ export class ContractsController {
id: l.id,
name: l.name,
topic: l.topic,
address: (l.location as any)?.address,
address: l.location?.address,
eventName: l.event.name,
}));
}
Expand Down
2 changes: 1 addition & 1 deletion server/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class TokenMint {
@IsString()
pool: string;

@IsString()
@IsNumberString()
amount: string;
}

Expand Down
2 changes: 1 addition & 1 deletion server/test/contracts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe('Smart Contracts', () => {
const listener = {
id: 'listener1',
topic: 'my-app',
location: { address: '0x123' } as any,
location: { address: '0x123' },
event: { name: 'event1' },
} as FireFlyContractListenerResponse;

Expand Down
10 changes: 4 additions & 6 deletions ui/src/components/Forms/BurnForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export const BurnForm: React.FC = () => {

const [tokenPools, setTokenPools] = useState<ITokenPool[]>([]);
const [pool, setPool] = useState<ITokenPool>();
const [amount, setAmount] = useState<number>(0);
const [amount, setAmount] = useState<string>('0');
const [tokenIndex, setTokenIndex] = useState<string | null>('');
const [refresh, setRefresh] = useState<number>(0);
const [tokenBalance, setTokenBalance] = useState<number>(0);
const [tokenBalance, setTokenBalance] = useState<string>('0');

useEffect(() => {
if (activeForm !== TUTORIALS.BURN) return;
Expand Down Expand Up @@ -80,7 +80,7 @@ export const BurnForm: React.FC = () => {

useEffect(() => {
if (!isFungible()) {
setAmount(1);
setAmount('1');
}
}, [pool, amount]);

Expand All @@ -96,9 +96,7 @@ export const BurnForm: React.FC = () => {
};

const handleAmountChange = (event: React.ChangeEvent<HTMLInputElement>) => {
if (parseInt(event.target.value)) {
setAmount(parseInt(event.target.value));
}
setAmount(event.target.value);
};

return (
Expand Down
10 changes: 4 additions & 6 deletions ui/src/components/Forms/MintForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ export const MintForm: React.FC = () => {
const { t } = useTranslation();

const [tokenPools, setTokenPools] = useState<ITokenPool[]>([]);
const [tokenBalance, setTokenBalance] = useState<number>(0);
const [tokenBalance, setTokenBalance] = useState<string>('0');

const [message] = useState<string | object | undefined>(
DEFAULT_MESSAGE_STRING
);

const [pool, setPool] = useState<ITokenPool>();
const [amount, setAmount] = useState<number>(1);
const [amount, setAmount] = useState<string>('1');
const [refresh, setRefresh] = useState<number>(0);

useEffect(() => {
if (activeForm !== TUTORIALS.MINT) {
setAmount(1);
setAmount('1');
return;
}
setPayloadMissingFields(!amount || !pool);
Expand Down Expand Up @@ -101,9 +101,7 @@ export const MintForm: React.FC = () => {
}, [pool, refresh]);

const handleAmountChange = (event: React.ChangeEvent<HTMLInputElement>) => {
if (parseInt(event.target.value)) {
setAmount(parseInt(event.target.value));
}
setAmount(event.target.value);
};

return (
Expand Down
14 changes: 6 additions & 8 deletions ui/src/components/Forms/TransferForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ export const TransferForm: React.FC = () => {

const [tokenPools, setTokenPools] = useState<ITokenPool[]>([]);
const [pool, setPool] = useState<ITokenPool>();
const [amount, setAmount] = useState<number>(1);
const [amount, setAmount] = useState<string>('1');
const [tokenVerifiers, setTokenVerifiers] = useState<IVerifiers[]>([]);
const [recipient, setRecipient] = useState<string>('');
const [tokenIndex, setTokenIndex] = useState<string | null>('');
const [tokenBalance, setTokenBalance] = useState<number>(0);
const [refresh, setRefresh] = useState<number>(0);
const [tokenBalance, setTokenBalance] = useState<string>('0');
const [refresh, setRefresh] = useState<string>('0');

useEffect(() => {
if (activeForm !== TUTORIALS.TRANSFER) {
setAmount(1);
setAmount('1');
return;
}
setPayloadMissingFields(
Expand Down Expand Up @@ -80,7 +80,7 @@ export const TransferForm: React.FC = () => {

useEffect(() => {
if (!isFungible()) {
setAmount(1);
setAmount('1');
}
}, [pool, amount]);

Expand Down Expand Up @@ -112,9 +112,7 @@ export const TransferForm: React.FC = () => {
};

const handleAmountChange = (event: React.ChangeEvent<HTMLInputElement>) => {
if (parseInt(event.target.value)) {
setAmount(parseInt(event.target.value));
}
setAmount(event.target.value);
};

const handleTokenIndexChange = (
Expand Down

0 comments on commit f8c8603

Please sign in to comment.