Skip to content

Commit

Permalink
Ensure first input.
Browse files Browse the repository at this point in the history
  • Loading branch information
msinkec committed Sep 1, 2023
1 parent 62ee919 commit 403c7ba
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/contracts/permissionedOrdinal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
ByteString,
PubKey,
PubKeyHash,
Sig,
Expand All @@ -9,6 +10,7 @@ import {
bsv,
hash160,
hash256,
int2ByteString,
method,
prop,
slice,
Expand Down Expand Up @@ -61,6 +63,15 @@ export class PermissionedOrdinal extends SmartContract {
// Disable isMint flag after first transfer
this.isMint = false

// Ensure the public method is called from the first input.
const outpoint =
this.ctx.utxo.outpoint.txid +
int2ByteString(this.ctx.utxo.outpoint.outputIndex, 4n)
assert(
slice(this.prevouts, 0n, 36n) == outpoint,
'contract must be spent via first input'
)

let stateScript = this.getStateScript()
if (isMint) {
// Cut leading inscription script.
Expand Down

0 comments on commit 403c7ba

Please sign in to comment.