Module: Sdp::Resources::Issuance

Included in:
Client
Defined in:
lib/sdp/resources/issuance.rb

Overview

Token issuance: the core lifecycle (list / get / create / deploy) and the supply actions (mint / burn), each action with a prepare variant for caller-signed (non-custodial) flows. Mint/burn/deploy are money-path and follow the same never-retry-on-write posture as transfers.

Out of scope at v0.2: the compliance actions (freeze/unfreeze, pause, authority, allowlist, seize, force-burn) — they roughly double the surface and target stablecoin issuers, not the general dev-tool path.

Instance Method Summary collapse

Instance Method Details

#burn_token(token_id, signing_wallet_id:, source:, amount:, memo: nil) ⇒ Object

POST /v1/issuance/tokens/:id/burn → Sdp::TokenTransaction. Custodial sign-and-send burn from source; never retried. amount is a DECIMAL token-amount string, same as #mint_token (NOT base units).



198
199
200
# File 'lib/sdp/resources/issuance.rb', line 198

def burn_token(token_id, signing_wallet_id:, source:, amount:, memo: nil)
  action_result(post(burn_path(token_id), burn_payload(signing_wallet_id, source, amount, memo)))
end

#create_token(name:, symbol:, signing_wallet_id:, decimals: nil, max_supply: nil, description: nil, uri: nil, image_url: nil, template: nil, mintable: nil, freezable: nil, requires_allowlist: nil) ⇒ Object

POST /v1/issuance/tokens → Sdp::Token. Registers the token record; it is NOT on-chain until #deploy_token. Never retried (write). maxSupply is a DECIMAL token-amount string (whole tokens, e.g. “1000000” = one million tokens) — SDP applies the token’s decimals, same convention as transfer amounts. NOT base units.



151
152
153
154
155
156
157
158
159
160
161
# File 'lib/sdp/resources/issuance.rb', line 151

def create_token(name:, symbol:, signing_wallet_id:, decimals: nil, max_supply: nil,
                 description: nil, uri: nil, image_url: nil, template: nil,
                 mintable: nil, freezable: nil, requires_allowlist: nil)
  payload = {
    name: name, symbol: symbol, signingWalletId: signing_wallet_id,
    decimals: decimals, maxSupply: max_supply, description: description,
    uri: uri, imageUrl: image_url, template: template,
    isMintable: mintable, isFreezable: freezable, requiresAllowlist: requires_allowlist
  }.compact
  Token.from_hash(token_node(post("/v1/issuance/tokens", payload)))
end

#deploy_token(token_id) ⇒ Object

POST /v1/issuance/tokens/:id/deploy → Sdp::Token (now on-chain). Custodial sign-and-send; never retried.



165
166
167
# File 'lib/sdp/resources/issuance.rb', line 165

def deploy_token(token_id)
  Token.from_hash(token_node(post(deploy_path(token_id))))
end

#get_token(token_id) ⇒ Object

GET /v1/issuance/tokens/:id → Sdp::Token



142
143
144
# File 'lib/sdp/resources/issuance.rb', line 142

def get_token(token_id)
  Token.from_hash(token_node(get("/v1/issuance/tokens/#{encode_path_segment(token_id)}")))
end

#list_tokens(status: nil, page: nil, page_size: nil) ⇒ Object

GET /v1/issuance/tokens → Enumerator yielding Sdp::Token. Auto-paginates on meta.hasMore (see Pagination); re-sends filters per page. Filters (camelCased on the wire): status:, page:, page_size:. (SDP v0.31 documents no other query filters on this endpoint.)



133
134
135
136
137
138
139
# File 'lib/sdp/resources/issuance.rb', line 133

def list_tokens(status: nil, page: nil, page_size: nil)
  query = { status: status, page: page, pageSize: page_size }.compact
  Pagination.enumerate(self, "/v1/issuance/tokens", query) do |response|
    rows = response.data.is_a?(Array) ? response.data : []
    rows.map { |token| Token.from_hash(token) }
  end
end

#mint_token(token_id, signing_wallet_id:, destination:, amount:, memo: nil) ⇒ Object

POST /v1/issuance/tokens/:id/mint → Sdp::TokenTransaction. Custodial sign-and-send mint to destination; never retried. amount is a DECIMAL token-amount string (whole tokens, e.g. “1.5”) — SDP scales it by the token’s decimals, NOT base units. The associated token account is on #token_account. (Noun-suffixed to match create_token/deploy_token and to leave room for a future #freeze_token without colliding with Ruby’s Object#freeze.)



183
184
185
# File 'lib/sdp/resources/issuance.rb', line 183

def mint_token(token_id, signing_wallet_id:, destination:, amount:, memo: nil)
  action_result(post(mint_path(token_id), mint_payload(signing_wallet_id, destination, amount, memo)))
end

#prepare_burn_token(token_id, signing_wallet_id:, source:, amount:, memo: nil) ⇒ Object

POST /v1/issuance/tokens/:id/burn/prepare → Sdp::PreparedTokenTransaction Builds — does not sign or send — the burn tx for caller-signed flows.



204
205
206
207
208
# File 'lib/sdp/resources/issuance.rb', line 204

def prepare_burn_token(token_id, signing_wallet_id:, source:, amount:, memo: nil)
  PreparedTokenTransaction.from_action(
    post("#{burn_path(token_id)}/prepare", burn_payload(signing_wallet_id, source, amount, memo)).data
  )
end

#prepare_deploy_token(token_id) ⇒ Object

POST /v1/issuance/tokens/:id/deploy/prepare → Sdp::PreparedTokenTransaction Builds — does not send — the deploy tx for caller-signed flows; the new mint address is on #mint.



172
173
174
# File 'lib/sdp/resources/issuance.rb', line 172

def prepare_deploy_token(token_id)
  PreparedTokenTransaction.from_deploy(post("#{deploy_path(token_id)}/prepare").data)
end

#prepare_mint_token(token_id, signing_wallet_id:, destination:, amount:, memo: nil) ⇒ Object

POST /v1/issuance/tokens/:id/mint/prepare → Sdp::PreparedTokenTransaction Builds — does not sign or send — the mint tx for caller-signed flows.



189
190
191
192
193
# File 'lib/sdp/resources/issuance.rb', line 189

def prepare_mint_token(token_id, signing_wallet_id:, destination:, amount:, memo: nil)
  PreparedTokenTransaction.from_action(
    post("#{mint_path(token_id)}/prepare", mint_payload(signing_wallet_id, destination, amount, memo)).data
  )
end