Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions interface/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@polywrap/random-interface",
"description": "Polywrap Random Interface",
"version": "0.10.0",
"scripts": {
"build": "npx polywrap build",
"deploy": "npx polywrap deploy -o deployment.json"
},
"devDependencies": {
"polywrap": "~0.10.3"
},
"publishConfig": {
"access": "public"
}
}
9 changes: 9 additions & 0 deletions interface/polywrap.deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
format: 0.2.0
jobs:
ipfs_deploy:
steps:
- name: ipfs_deploy
package: ipfs
uri: fs/./build
config:
gatewayUri: https://ipfs.wrappers.io
47 changes: 47 additions & 0 deletions interface/polywrap.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
type Module {
"""
Generates a random Int within the range [min, max).
"""
nextInt(min: Int, max: Int): Int!

"""
Generates a random UInt within the range [min, max).
"""
nextUInt(min: UInt, max: UInt): UInt!

"""
Generates a random Float within the range [min, max).
"""
nextFloat(min: Int, max: Int): BigNumber!

"""
Generates a random Boolean value.
"""
nextBoolean: Boolean!

"""
Generates a random byte sequence of the specified length.
"""
nextBytes(length: Int!): Bytes!

"""
Generates a random string of the specified length.
"""
nextString(length: Int!): String!

"""
Generates a list of random integers of the given length, each within the range [min, max).
"""
nextInts(length: Int, min: Int, max: Int): [Int!]!

"""
Generates an array of randomly sorted integers of the given length.
"""
shuffle(length: Int): [Int!]!

"""
Sets the seed of the random number generator for replicable results.
"""
seed(seed: Int!): Boolean!
}

6 changes: 6 additions & 0 deletions interface/polywrap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
format: 0.3.0
project:
name: random-interface
type: interface
source:
schema: ./polywrap.graphql
50 changes: 50 additions & 0 deletions interface/resources/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Random Wrapper Interface

| Version | URI | WRAP Version |
|-|-----------------------------------------------------------------------------------------|-|
| 1.0.0 | [`wrap://ens/wraps.eth:random@1.0.0`](https://wrappers.io/v/ens/wraps.eth:random@1.0.0) | 0.1 |

## Interface
```graphql
type Module {
# get a random Int, bounded by [min, max)
nextInt(min: Int, max: Int): Int!

# get a random UInt, bounded by [min, max)
nextUInt(min: UInt, max: UInt): UInt!

# get a random Float, bounded by [min, max)
nextFloat(min: Int, max: Int): BigNumber!

# get a random Boolean
nextBoolean: Boolean!

# get a random byte sequence of the given length
nextBytes(length: Int!): Bytes!

# get a random string of the given length
nextString(length: Int!): String!

# get a list of random integers with the given length, bounded by [min, max)
nextInts(length: Int, min: Int, max: Int): [Int!]!

# an array of randomly sorted integers
shuffle(length: Int): [Int!]!

# set the seed of the random number generator for replicable results
seed(seed: Int!): Boolean!
}
```

## Usage
```graphql
#import * from "ens/wraps.eth:random@1.0.0"
```

And implement the interface methods within your programming language of choice.

## Source Code
[Link](https://github.com/polywrap/std/random)

## Known Implementations
[Link](https://github.com/polywrap/random/tree/master/implementations)
Loading