Skip to content

Commit

Permalink
Release 5.25.1 (#1665)
Browse files Browse the repository at this point in the history
* [BUG] fixes an incorrect reference to the old create contract class for v2 (#1661)

* fixes an incorrect reference to the old create contract class for v2

* adds test for create contract v1 in sub invoke

* account for invocations that follow the deployer pattern in create contract types, add branch for craete contract v2 in invocation crawler for sac cases

* updates tests for sac create constructor args and adds optional component to render them

* removes comment in tests

* adds unit test and jest view tests for creater contract deployer pattern (#1668)
  • Loading branch information
aristidesstaffieri authored Nov 14, 2024
1 parent 1a85fb3 commit 64d0057
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 15 deletions.
92 changes: 92 additions & 0 deletions extension/src/popup/helpers/__tests__/soroban.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import {
Address,
Keypair,
Operation,
scValToNative,
TransactionBuilder,
xdr,
} from "stellar-sdk";

import { getInvocationArgs, buildInvocationTree } from "../soroban";
import { TEST_PUBLIC_KEY } from "popup/__testHelpers__";
import { TESTNET_NETWORK_DETAILS } from "@shared/constants/stellar";

describe("getInvocationArgs", () => {
it("can parse a create contract v1 xdr class", () => {
const assetCode = "KHL";
const assetType = new xdr.AlphaNum4({
assetCode: Buffer.from(assetCode),
issuer: Keypair.fromPublicKey(TEST_PUBLIC_KEY).xdrAccountId(),
});
const args = new xdr.CreateContractArgs({
contractIdPreimage: xdr.ContractIdPreimage.contractIdPreimageFromAsset(
xdr.Asset.assetTypeCreditAlphanum4(assetType),
),
executable: xdr.ContractExecutable.contractExecutableStellarAsset(),
});
const authorizedFn =
xdr.SorobanAuthorizedFunction.sorobanAuthorizedFunctionTypeCreateContractHostFn(
args,
);
const authorizedInvocation = new xdr.SorobanAuthorizedInvocation({
function: authorizedFn,
subInvocations: [],
});
const invocationArgs = getInvocationArgs(authorizedInvocation);
expect(invocationArgs).toEqual({
type: "sac",
asset: `${assetCode}:${TEST_PUBLIC_KEY}`,
});
});
it("can parse a create contract v2 xdr class", () => {
const assetCode = "KHL";
const assetType = new xdr.AlphaNum4({
assetCode: Buffer.from(assetCode),
issuer: Keypair.fromPublicKey(TEST_PUBLIC_KEY).xdrAccountId(),
});
const args = new xdr.CreateContractArgsV2({
contractIdPreimage: xdr.ContractIdPreimage.contractIdPreimageFromAsset(
xdr.Asset.assetTypeCreditAlphanum4(assetType),
),
executable: xdr.ContractExecutable.contractExecutableStellarAsset(),
constructorArgs: [new Address(TEST_PUBLIC_KEY).toScVal()],
});
const authorizedFn =
xdr.SorobanAuthorizedFunction.sorobanAuthorizedFunctionTypeCreateContractV2HostFn(
args,
);
const authorizedInvocation = new xdr.SorobanAuthorizedInvocation({
function: authorizedFn,
subInvocations: [],
});
const invocationArgs = getInvocationArgs(authorizedInvocation);
expect(invocationArgs).toEqual({
type: "sac",
asset: `${assetCode}:${TEST_PUBLIC_KEY}`,
args: args.constructorArgs(),
});
});
it("can parse a create contract v2 xdr for the deployer pattern", () => {
const xdr =
"AAAAAgAAAABngBTmbmUycqG2cAMHcomSR80dRzGtKzxM6gb3yySD5AHs+0gAAAGnAAAALwAAAAEAAAAAAAAAAAAAAABnNhxOAAAAAAAAAAEAAAAAAAAAGAAAAAAAAAAB7NAU3oaYgmlpUsvzZfe9VHPtVP2GAv4RaBFqcvtQCMUAAAAGZGVwbG95AAAAAAAIAAAAEgAAAAAAAAAAZ4AU5m5lMnKhtnADB3KJkkfNHUcxrSs8TOoG98skg+QAAAANAAAAIBGajC6rX3MsGNdSFCbhA4FR+oN1BsY93KF8aFHi+/lGAAAADQAAACB0NfLZSuf94c266AzunEfWgf2OvWrq5gOx/XmYqA3XtAAAAA8AAAAKaW5pdGlhbGl6ZQAAAAAAEAAAAAEAAAAUAAAAEgAAAAAAAAAAZ4AU5m5lMnKhtnADB3KJkkfNHUcxrSs8TOoG98skg+QAAAADAAAAAAAAAA4AAAAFUGl5YWwAAAAAAAAOAAAAAlBUAAAAAAASAAAAAAAAAABngBTmbmUycqG2cAMHcomSR80dRzGtKzxM6gb3yySD5AAAAAoAAAAAAAAAAAAAAA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AAAAEgAAAAAAAAAAZ4AU5m5lMnKhtnADB3KJkkfNHUcxrSs8TOoG98skg+QAAAASAAAAAAAAAABBWfX66Y/Wa6aoucHtj3eTMqT3bADljjqcH8KPAS6nOgAAAAoAAAAAAAAAAAAAAAAdNM6AAAAAAAAAAAEAAAAAAAAABQAAAAYAAAAB15KLcsJwPM/q9+uf9O9NUEpVqLl5/JtFDqLIQrTRzmEAAAAUAAAAAQAAAAYAAAAB7NAU3oaYgmlpUsvzZfe9VHPtVP2GAv4RaBFqcvtQCMUAAAAQAAAAAQAAAAEAAAAPAAAAEFdoaXRlbGlzdEVuYWJsZWQAAAABAAAABgAAAAHs0BTehpiCaWlSy/Nl971Uc+1U/YYC/hFoEWpy+1AIxQAAABQAAAABAAAABxGajC6rX3MsGNdSFCbhA4FR+oN1BsY93KF8aFHi+/lGAAAAB7dySH//03E9J30DGFshS4flCC2H7kUg/8E4RiyE3MqLAAAABAAAAAAAAAAAQVn1+umP1mumqLnB7Y93kzKk92wA5Y46nB/CjwEupzoAAAAAAAAAAGeAFOZuZTJyobZwAwdyiZJHzR1HMa0rPEzqBvfLJIPkAAAABgAAAAGYWnA2KaPUztwlj674BNzaTUHHYW0fEx8VhdOE6ciRVAAAABAAAAABAAAAAgAAAA8AAAAHQmFsYW5jZQAAAAASAAAAAAAAAABngBTmbmUycqG2cAMHcomSR80dRzGtKzxM6gb3yySD5AAAAAEAAAAGAAAAAZhacDYpo9TO3CWPrvgE3NpNQcdhbR8THxWF04TpyJFUAAAAFAAAAAEAbsVOAAC4OAAABigAAAAAAez65AAAAAA=";
const tx = TransactionBuilder.fromXDR(
xdr,
TESTNET_NETWORK_DETAILS.networkPassphrase,
);
const op = tx.operations[0];
for (const authEntry of op.auth || []) {
const rootInvocation = authEntry.rootInvocation();
const tree = buildInvocationTree(rootInvocation);
expect(tree.type).toEqual("execute");
expect(tree.args.source).toEqual(
"CDWNAFG6Q2MIE2LJKLF7GZPXXVKHH3KU7WDAF7QRNAIWU4X3KAEMLZTN",
);
expect(tree.args.function).toEqual("deploy");
for (const subInvocation of tree.invocations) {
if (subInvocation.type === "create") {
expect(subInvocation.args.constructorArgs).toStrictEqual([]);
}
}
}
});
});
36 changes: 30 additions & 6 deletions extension/src/popup/helpers/soroban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,9 @@ export function buildInvocationTree(root: xdr.SorobanAuthorizedInvocation) {
}

// sorobanAuthorizedFunctionTypeCreateContractHostFn
case 2:
case 1: {
const _inner = inner as xdr.CreateContractArgs;
const _inner = inner as xdr.CreateContractArgs | xdr.CreateContractArgsV2;
output.type = "create";
output.args = {} as {
type: string;
Expand Down Expand Up @@ -291,6 +292,11 @@ export function buildInvocationTree(root: xdr.SorobanAuthorizedInvocation) {
hash: exec.wasmHash().toString("hex"),
address: Address.fromScAddress(details.address()).toString(),
};
// create contract V2
if (fn.switch().value === 2) {
const v2Args = _inner as xdr.CreateContractArgsV2;
output.args.constructorArgs = v2Args.constructorArgs();
}
break;
}

Expand All @@ -300,6 +306,11 @@ export function buildInvocationTree(root: xdr.SorobanAuthorizedInvocation) {
output.args.asset = Asset.fromOperation(
preimage.fromAsset(),
).toString();
// create contract V2
if (fn.switch().value === 2) {
const v2Args = _inner as xdr.CreateContractArgsV2;
output.args.constructorArgs = v2Args.constructorArgs();
}
break;

default:
Expand Down Expand Up @@ -436,6 +447,7 @@ export interface FnArgsCreateWasm {
export interface FnArgsCreateSac {
type: "sac";
asset: string;
args?: xdr.ScVal[];
}

type InvocationArgs = FnArgsInvoke | FnArgsCreateWasm | FnArgsCreateSac;
Expand All @@ -444,7 +456,7 @@ const isInvocationArg = (
invocation: InvocationArgs | undefined,
): invocation is InvocationArgs => !!invocation;

function getInvocationArgs(
export function getInvocationArgs(
invocation: xdr.SorobanAuthorizedInvocation,
): InvocationArgs | undefined {
const fn = invocation.function();
Expand All @@ -465,7 +477,10 @@ function getInvocationArgs(
// sorobanAuthorizedFunctionTypeCreateContractHostFn
case 2:
case 1: {
const _invocation = fn.createContractHostFn();
const _invocation =
fn.switch().value === 2
? fn.createContractV2HostFn()
: fn.createContractHostFn();
const [exec, preimage] = [
_invocation.executable(),
_invocation.contractIdPreimage(),
Expand Down Expand Up @@ -493,11 +508,20 @@ function getInvocationArgs(
}

// contractExecutableStellarAsset
case 1:
return {
case 1: {
const sacDetails = {
type: "sac",
asset: Asset.fromOperation(preimage.fromAsset()).toString(),
};
} as FnArgsCreateSac;

if (fn.switch().value === 2) {
sacDetails.args = (
_invocation as xdr.CreateContractArgsV2
).constructorArgs();
}

return sacDetails;
}

default:
throw new Error(`unknown creation type: ${JSON.stringify(exec)}`);
Expand Down
29 changes: 20 additions & 9 deletions extension/src/popup/views/ReviewAuth/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,12 @@ const AuthDetail = ({
async function getIsToken() {
try {
const transfers = [];
const isToken = await getIsTokenSpec({
contractId: rootJson.args.source,
networkDetails,
});
const isToken = !rootJson.args.source
? false
: await getIsTokenSpec({
contractId: rootJson.args.source,
networkDetails,
});
if (isToken && rootJson.args.function === "transfer") {
transfers.push({
contractId: rootJson.args.source as string,
Expand All @@ -366,10 +368,12 @@ const AuthDetail = ({
// check for sub transfers
// eslint-disable-next-line no-restricted-syntax
for (const subInvocation of rootJson.invocations) {
const isSubInvokeToken = await getIsTokenSpec({
contractId: subInvocation.args.source,
networkDetails,
});
const isSubInvokeToken = !subInvocation.args.source
? false
: await getIsTokenSpec({
contractId: subInvocation.args.source,
networkDetails,
});
if (isSubInvokeToken && subInvocation.args.function === "transfer") {
transfers.push({
contractId: subInvocation.args.source as string,
Expand All @@ -381,6 +385,7 @@ const AuthDetail = ({
}
setAuthTransfers(transfers);
setCheckingTransfers(false);
setLoading(false);
} catch (error) {
console.error(error);
setCheckingTransfers(false);
Expand All @@ -391,6 +396,7 @@ const AuthDetail = ({
getIsToken();
} else {
setCheckingTransfers(false);
setLoading(false);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isInvokeContract, rootJsonDepKey]);
Expand Down Expand Up @@ -439,6 +445,7 @@ const AuthDetail = ({
_getTokenDetails();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [transfersDepKey]);

return (
<div className="AuthDetail" data-testid="AuthDetail">
{isLoading || isCheckingTransfers ? (
Expand Down Expand Up @@ -493,7 +500,10 @@ const AuthDetail = ({
))}
{createWasms.map((detail) => (
<React.Fragment key={detail.hash}>
<div className="AuthDetail__TitleRow">
<div
className="AuthDetail__TitleRow"
data-testid="AuthDetail__createWasmInvocation"
>
<Icon.CodeSnippet01 />
<h5>Contract Creation</h5>
</div>
Expand Down Expand Up @@ -530,6 +540,7 @@ const AuthDetail = ({
operationKey={t("Asset")}
operationValue={truncateString(detail.asset)}
/>
{detail.args && <KeyValueInvokeHostFnArgs args={detail.args} />}
</div>
</React.Fragment>
))}
Expand Down
44 changes: 44 additions & 0 deletions extension/src/popup/views/__tests__/ReviewAuth.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,47 @@ it("renders all subinvocations", async () => {
const invocations = screen.queryAllByTestId("AuthDetail__invocation");
expect(invocations.length).toBe(3);
});

it("renders create contract args for subinvocations", async () => {
jest.spyOn(helpersUrls, "decodeString").mockImplementation(() =>
JSON.stringify({
transactionXdr:
"AAAAAgAAAABngBTmbmUycqG2cAMHcomSR80dRzGtKzxM6gb3yySD5AHs+0gAAAGnAAAALwAAAAEAAAAAAAAAAAAAAABnNhxOAAAAAAAAAAEAAAAAAAAAGAAAAAAAAAAB7NAU3oaYgmlpUsvzZfe9VHPtVP2GAv4RaBFqcvtQCMUAAAAGZGVwbG95AAAAAAAIAAAAEgAAAAAAAAAAZ4AU5m5lMnKhtnADB3KJkkfNHUcxrSs8TOoG98skg+QAAAANAAAAIBGajC6rX3MsGNdSFCbhA4FR+oN1BsY93KF8aFHi+/lGAAAADQAAACB0NfLZSuf94c266AzunEfWgf2OvWrq5gOx/XmYqA3XtAAAAA8AAAAKaW5pdGlhbGl6ZQAAAAAAEA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ternal, "getIsTokenSpec")
.mockImplementation(() => Promise.resolve(false));

render(
<Wrapper
state={{
auth: {
allAccounts: mockAccounts,
publicKey: mockAccounts[0].publicKey,
},
settings: {
isExperimentalModeEnabled: true,
networkDetails: {
...defaultSettingsState.networkDetails,
networkPassphrase: "Test SDF Future Network ; October 2022",
},
},
}}
>
<ReviewAuth />
</Wrapper>,
);

await waitFor(() => screen.getByTestId("AuthDetail"));
expect(screen.getByTestId("AuthDetail")).toBeDefined();
await waitFor(() => screen.getByTestId("AuthDetail__transfers"));
const invocations = screen.queryAllByTestId("AuthDetail__invocation");
expect(invocations.length).toBe(1);
const subInvocations = screen.queryAllByTestId(
"AuthDetail__createWasmInvocation",
);
expect(subInvocations.length).toBe(1);
});

0 comments on commit 64d0057

Please sign in to comment.