@faremeter/payment-solana 0.10.2 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/exact/verify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAYrE,OAAO,EAEL,KAAK,4BAA4B,EAElC,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/exact/verify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAYrE,OAAO,EAEL,KAAK,4BAA4B,EAElC,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAqHjD,wBAAsB,kBAAkB,CACtC,kBAAkB,EAAE,4BAA4B,EAChD,mBAAmB,EAAE,uBAAuB,EAC5C,kBAAkB,EAAE,SAAS,EAC7B,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,OAAO,CAAC,CAkGlB"}
|
package/dist/src/exact/verify.js
CHANGED
|
@@ -69,16 +69,20 @@ async function verifyTransferInstruction(instruction, paymentRequirements, desti
|
|
|
69
69
|
transfer.accounts.mint.address === paymentRequirements.asset &&
|
|
70
70
|
transfer.accounts.destination.address === destination);
|
|
71
71
|
}
|
|
72
|
-
function verifyCreateATAInstruction(instruction) {
|
|
72
|
+
function verifyCreateATAInstruction(instruction, facilitatorAddress) {
|
|
73
73
|
if (!instruction.data || !instruction.accounts) {
|
|
74
74
|
return false;
|
|
75
75
|
}
|
|
76
76
|
try {
|
|
77
|
-
parseCreateAssociatedTokenInstruction({
|
|
77
|
+
const createInstruction = parseCreateAssociatedTokenInstruction({
|
|
78
78
|
accounts: instruction.accounts,
|
|
79
79
|
programAddress: instruction.programAddress,
|
|
80
80
|
data: new Uint8Array(instruction.data),
|
|
81
81
|
});
|
|
82
|
+
if (createInstruction.accounts.payer.address === facilitatorAddress) {
|
|
83
|
+
logger.error("Dropping transaction where the facilitator pays for a token account creation");
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
82
86
|
return true;
|
|
83
87
|
}
|
|
84
88
|
catch {
|
|
@@ -99,6 +103,7 @@ export async function isValidTransaction(transactionMessage, paymentRequirements
|
|
|
99
103
|
tokenProgram: TOKEN_PROGRAM_ADDRESS,
|
|
100
104
|
});
|
|
101
105
|
const instructions = transactionMessage.instructions;
|
|
106
|
+
const facilitatorBase58 = facilitatorAddress.toBase58();
|
|
102
107
|
if (instructions.length === 3) {
|
|
103
108
|
// Make typescript happy...
|
|
104
109
|
const [ix0, ix1, ix2] = instructions;
|
|
@@ -119,7 +124,7 @@ export async function isValidTransaction(transactionMessage, paymentRequirements
|
|
|
119
124
|
return false;
|
|
120
125
|
}
|
|
121
126
|
}
|
|
122
|
-
return await verifyTransferInstruction(ix2, paymentRequirements, destination,
|
|
127
|
+
return await verifyTransferInstruction(ix2, paymentRequirements, destination, facilitatorBase58);
|
|
123
128
|
}
|
|
124
129
|
else if (instructions.length === 4) {
|
|
125
130
|
const [ix0, ix1, ix2, ix3] = instructions;
|
|
@@ -140,8 +145,8 @@ export async function isValidTransaction(transactionMessage, paymentRequirements
|
|
|
140
145
|
return false;
|
|
141
146
|
}
|
|
142
147
|
}
|
|
143
|
-
return (verifyCreateATAInstruction(ix2) &&
|
|
144
|
-
(await verifyTransferInstruction(ix3, paymentRequirements, destination,
|
|
148
|
+
return (verifyCreateATAInstruction(ix2, facilitatorBase58) &&
|
|
149
|
+
(await verifyTransferInstruction(ix3, paymentRequirements, destination, facilitatorBase58)));
|
|
145
150
|
}
|
|
146
151
|
return false;
|
|
147
152
|
}
|