= ({
network={network}
contract={contract}
language={language}
+ type="Getter"
/>
))}
>
)}
- Send internal message:
+ Send internal message: ({abi?.setters?.length || '-'})
{language !== 'tact' && (
<>
@@ -206,6 +207,21 @@ const ContractInteraction: FC = ({
>
)}
+ {abi && abi.setters.length > 0 && (
+ <>
+ {abi.setters.map((item, i) => (
+
+ ))}
+ >
+ )}
);
};
diff --git a/src/hooks/contract.hooks.ts b/src/hooks/contract.hooks.ts
index d281752..5e317b9 100644
--- a/src/hooks/contract.hooks.ts
+++ b/src/hooks/contract.hooks.ts
@@ -32,6 +32,7 @@ export function useContractAction() {
return {
deployContract,
sendMessage,
+ callSetter,
callGetter,
};
async function deployContract(
@@ -44,12 +45,10 @@ export function useContractAction() {
let codeCell = Cell.fromBoc(Buffer.from(codeBOC, 'base64'))[0];
// Amount to send to contract. Gas fee
- const value = toNano('0.002');
+ const value = toNano('0.02');
let stateInit: StateInit = {};
- const cellBuilderRef = document.querySelector('.cell-builder-ref');
if (project.language === 'tact') {
- const _contractInit = (cellBuilderRef as any)?.contentWindow
- ?.contractInit;
+ const _contractInit = (window as any).contractInit;
stateInit = {
code: _contractInit.init.code,
data: _contractInit.init.data,
@@ -63,12 +62,8 @@ export function useContractAction() {
if (network.toUpperCase() === 'SANDBOX' && sandboxBlockchain) {
if (project.language === 'tact') {
- const _contractInit = (cellBuilderRef as any)?.contentWindow
- ?.contractInit;
-
+ const _contractInit = (window as any).contractInit;
const _userContract = sandboxBlockchain.openContract(_contractInit);
- (window as any).userContract = _userContract;
-
// TODO: Handle last parameter i.e. message
const sender = sandboxWallet!!.getSender();
const queryId = BigInt(0);
@@ -88,24 +83,15 @@ export function useContractAction() {
};
}
}
- const response = await _userContract.send(
- sender,
- { value: toNano(1) },
- messageParams
- );
- const response1 = await _userContract.send(
+ const response = await _userContract.send(
sender,
- { value: toNano(1) },
{
- $$type: 'Add',
- queryId: BigInt(0),
- amount: BigInt(5),
- }
+ value,
+ },
+ messageParams
);
- const data = await _userContract.getCounter();
-
return {
address: _userContract.address.toString(),
contract: _userContract,
@@ -204,6 +190,42 @@ export function useContractAction() {
}
}
+ async function callSetter(
+ contractAddress: string,
+ methodName: string,
+ contract: SandboxContract | null = null,
+ language: ContractLanguage,
+ stack?: TupleItem[],
+ network?: Network | Partial
+ ) {
+ if (network === 'SANDBOX' && contract) {
+ const { sandboxWallet } = globalWorkspace;
+
+ const sender = sandboxWallet!!.getSender();
+
+ let messageParams = {
+ $$type: methodName,
+ };
+ stack?.forEach((item: any) => {
+ messageParams = {
+ ...messageParams,
+ [item.name]: BigInt(item.value),
+ };
+ });
+
+ if (language === 'tact') {
+ const response = await (contract as any).send(
+ sender,
+ { value: toNano('0.02') },
+ messageParams
+ );
+ return { message: 'Message sent successfully' };
+ } else {
+ }
+ return;
+ }
+ }
+
async function callGetter(
contractAddress: string,
methodName: string,
@@ -235,7 +257,6 @@ export function useContractAction() {
};
}
});
-
if (network === 'SANDBOX' && contract) {
let responseValues = [];
if (language === 'tact') {
diff --git a/src/hooks/project.hooks.ts b/src/hooks/project.hooks.ts
index 13bd9a7..aeb3608 100644
--- a/src/hooks/project.hooks.ts
+++ b/src/hooks/project.hooks.ts
@@ -212,19 +212,35 @@ export function useProjectActions() {
return {
name: parameter.name,
type: parameter.type,
+ format: parameter.format,
+ optional: parameter.optional,
};
}),
};
});
- const setters = (output.abi as any)?.receivers?.map((item: any) => {
- let fields = [];
+ let setters: any = [];
+ (output.abi as any)?.receivers?.forEach((item: any) => {
+ if (item.message.type === 'Deploy') {
+ return;
+ }
if (item.message.type) {
- fields = (output.abi as any).types.find(
+ const singleItem = (output.abi as any).types.find(
(type: any) => type.name === item.message.type
);
+ const singleField = {
+ name: singleItem.name,
+ parameters: singleItem.fields.map((parameter: any) => {
+ return {
+ name: parameter.name,
+ type: parameter.type.type,
+ format: parameter.type.format,
+ optional: parameter.type.optional,
+ };
+ }),
+ };
+ setters.push(singleField);
}
- return fields;
});
let ctx = new CompilerContext({ shared: {} });